-
AuthorPosts
-
May 14, 2021 at 8:43 pm #1300422
Hello,
I searched on your forum but I can’t find…
With CPT UI and ACF no problem, I found tutorials.With CPT UI I have
– 1 post type – Name: Publications / slug: publication_post
– 1 taxonomy – slug: publi_categoryWith ACF I have 6 fields (slugs : publi_annee / publi_auteur / publi_revue / publi_abstract / publi_fichier)
So I have my Publications Tab, my fields, all is good. I saved a post but the page is displayed it is empty.
In my child theme, I copy single.php, create single-publication_post.php and replace
get_template_part( 'includes/loop', 'index' );
by
get_template_part( 'publication_post' );
I read this in tutorial, but it does not work on your theme. So what is the procedure for seeing my custom post already?
Thanks
SebMay 17, 2021 at 8:55 pm #1300811So please ?
I program but I am not a developer …May 18, 2021 at 2:12 am #1300848Hi,
Thank you for the inquiry.
Did you actually create a publication_post template? Custom post types made from CPT UI should display immediately without creating a special template using a Blog Posts element. Please post the link to the page where you are trying to display the custom posts so that we could check it properly.
Best regards,
IsmaelMay 18, 2021 at 7:52 pm #1301069Hi
I finally reset the dev site and reinstalled everything (I had done too many tests with too many plugins …)
And I finally have my post displayed but not the custom fields in it (just the title)
So how do you
– include these custom fields to see them in the post and
– customize the display of data in list mode and in post detail.
Only for publication_post of course.
Thank you
SebMay 19, 2021 at 4:43 am #1301100Hi Seb,
Please post us your login credentials (in the “private data” field), so we can take a look at your backend.
- Install and activate ” Temporary Login Without Password “.
- Go to ” Users > Temporary Logins ” on the left-side menu.
- Click ” Create New “.
- Add the email address for the account ( you can use (Email address hidden if logged out) ), as well as the ” Role ” making that the highest possible and the expiry about four days
( to be sure that we have enough time to debug ). - Click ” Submit “.
- You’ll now have a temporary account. Please provide us here in the private section the URL, so we can login and help you out.
When your issue is fixed, you can always remove the plugin!
If you prefer to not use the plugin, you can manually create an admin user and post the login credentials in the “private data” field.Best regards,
NikkoMay 19, 2021 at 6:33 pm #1301244Hi Nikko
I prefer an admin account, simpler in terms of deadline
Codes in private
Best regards
SebMay 21, 2021 at 7:07 am #1301531Hi,
Would you like to display the custom fields in the single post page (see private field)? If yes, then you have to edit the includes > loop-index.php file and use ACF’s get_field function to get the value of the custom field and render it to the page. For example, in the loop-index.php file, look for this code around line
// echo the post content if ( $blog_style == 'bloglist-excerpt') { the_excerpt(); echo '<div class="read-more-link"><a href="' . get_permalink() . '" class="more-link">' . __( 'Read more', 'avia_framework' ) . '<span class="more-link-arrow"></span></a></div>'; }
Above that code, add this one.
$publi_revue = get_field( "publi_revue" ); echo '<div class="av-publi-revue">' . $publi_revue . '</div>';
This should render the value of the Revue field above the post content, inside a container with the class name av-publi-revue.
Best regards,
IsmaelMay 21, 2021 at 6:12 pm #1301697Hi
it works indeed, already tested.
The problem is :
1. It affects all posts, even classic ones
2. With just one custom post it doesn’t work, so how can I do that when I have multiple custom posts?
in one loop-index file, it is not maintainable and it does not work as it shouldSo how do you do it?
it is not possible to create a template in the child for each custom post?
without affecting the classic posts of courseRegards
SebMay 24, 2021 at 5:22 am #1301906Hi,
You can check for the current post type or you can wrap the code inside a conditional tag. Example.
if(get_post_type() == "publication_post") { $publi_revue = get_field( "publi_revue" ); echo '<div class="av-publi-revue">' . $publi_revue . '</div>'; }
If you want to create a dedicated template file for the post type, please check the documentation
// https://developer.wordpress.org/themes/template-files-section/custom-post-type-template-files/
TL;DR You will have to create a file called single-publication_post.php.
Best regards,
IsmaelMay 24, 2021 at 9:43 am #1301940Hi Ismael
Thank you for your answer.I try this > single-publication_post.php > publication_post/loop-index.php for my publication post.
If I put the code in single-publication_post.php (like this : get_post_type( get_the_ID() ) == ‘publication_post’ or this : is_singular( ‘publication_post’ ). It works…. only on the post, not on a list on post.
So the only way is to copy/modify the includes/loop-index.php and in the loop add
if(get_post_type() == "publication_post") { my code..... }
and it works for post and post list.
So in my case (custom post view and custom list view) no single-publication_post.php is necessary at the end because everything is in the loop-index file – and that it is this file that manages the post preview and the post lists
it’s not what I would have liked but it worksThe only thing that would allow me to do what I want (one loop-index per custom post), it would be to find the code say, if the page contains posts of type publication_post> particular loop file
I don’t find. But maybe this is not possible with the natural functioning of wordpress. And that I have persisted for several days for nothing :)if you have the answer to this question, I am interested, otherwise you can put the subject as resolved
Thanks for your help
Regards
Seb- This reply was modified 3 years, 6 months ago by Astaryne.
May 25, 2021 at 8:52 pm #1302289Hi,
The following folder structure is actually not valid…
publication_post/loop-index.php
.. unless you have modified the the single-publication_post.php file, and change this code.
get_template_part( 'includes/loop', 'index' );
This tells WP to get a template inside the includes folder with the name loop-index.
But using a conditional function as we suggested above should be enough in this case.
Best regards,
IsmaelMay 26, 2021 at 8:21 pm #1302457Hi Ismael,
As I said > obliged to put the condition in the loop
And it does indeed work.
For a custom post it’s fine, if we have ten, the loop file starts to get complicated :)Solved
Regards
Seb -
AuthorPosts
- The topic ‘CPT UI + ACF with your theme’ is closed to new replies.