- This topic has 14 replies, 3 voices, and was last updated 7 years, 6 months ago by
Tom.
-
AuthorPosts
-
August 27, 2018 at 11:03 am #661382
Laurent
Hi,
Thanks for the theme it’s really great.
I’m using custom post types that I allow to be displayed on the blog use a filter on pre_get_posts. That works, I can see my custom post types.
However, even though I have set “display category / tags / date” in theme customization, they don’t appear.
Do I have to do something ?
Thanks
August 27, 2018 at 7:20 pm #661738Tom
Lead DeveloperLead DeveloperHi there,
Try these functions:
add_action( 'generate_after_entry_title', function() { $post_types = array( 'one-post-type', 'another-post-type', ); if ( in_array( get_post_type(), $post_types ) ) : ?> <div class="entry-meta"> <?php generate_posted_on(); ?> </div><!-- .entry-meta --> <?php endif; } ); add_action( 'generate_after_entry_content', function() { $post_types = array( 'one-post-type', 'another-post-type', ); if ( in_array( get_post_type(), $post_types ) ) : ?> <footer class="entry-meta"> <?php generate_entry_meta(); if ( is_single() ) { generate_content_nav( 'nav-below' ); } ?> </footer><!-- .entry-meta --> <?php endif; } );Let me know if this helps or not 🙂
August 28, 2018 at 12:00 am #661857Laurent
Hi,
Great ! It works !
Are there other places in GeneratePress where I need to specificy things for custom post types ?
Thanks a lot
August 28, 2018 at 10:00 am #662428Tom
Lead DeveloperLead DeveloperNope, that should be it 🙂
Glad I could help!
September 10, 2018 at 4:25 am #673101Alain Aubry
I tried this:
add_action( 'generate_after_entry_content', 'indigo_cpt_footer_meta' ); function indigo_cpt_footer_meta() { $post_types = array( 'colaborador', 'actividade', 'evento' ); if ( in_array( get_post_type(), $post_types ) ) : ?> <footer class="entry-meta"> <?php generate_entry_meta(); if ( is_single() ) { generate_content_nav( 'nav-below' ); } ?> </footer><!-- .entry-meta --> <?php endif; }But the only thing I got is:
<footer class="entry-meta"> <nav id="nav-below" class="post-navigation"> <span class="screen-reader-text">Navegação de artigos</span> </nav><!-- #nav-below --> </footer>September 10, 2018 at 3:18 pm #673788Tom
Lead DeveloperLead DeveloperCan you link me to one of those post types?
September 10, 2018 at 3:31 pm #673797Alain Aubry
September 10, 2018 at 7:57 pm #673939Tom
Lead DeveloperLead DeveloperHmm, how are you adding that code?
September 11, 2018 at 12:12 am #674036Alain Aubry
Hi Tom
A child theme based on yours, with lots of functions, many from yours, others well documented and tested, some my own experiments. I will send a login.
Thanks
September 11, 2018 at 9:16 am #674508Tom
Lead DeveloperLead DeveloperIn your custom function, find this line:
generate_entry_meta();And add this after it:
echo 'hi!';Does the “hi!” text appear within your CPTs?
September 11, 2018 at 11:29 am #674624Alain Aubry
I tried locally, yes it shows in the right spot!
But wait, those 3 CPT’s don’t have categories or tags.
So the point is about
generate_content_nav().
This one is generating<span class="screen-reader-text">
Also is generating</nav><!-- #nav-below -->…September 11, 2018 at 6:38 pm #674864Tom
Lead DeveloperLead DeveloperSo that means this function isn’t firing: https://github.com/tomusborne/generatepress/blob/35fe967ca7351a0517d258ab5c73150aa40d1f9a/inc/structure/post-meta.php#L159-L185
Do these custom post types have categories and tags?
September 12, 2018 at 12:20 am #675000Alain Aubry
Those 3 CPT’s don’t have categories or tags.
‘colaboradores’ has ‘grupos’, ‘actividades’ has ‘tipos’ but these does not count.I am really interested in the next/previous links. I cant discard the use of
generate_entry_meta().
So the point is aboutgenerate_content_nav().Thanks
September 12, 2018 at 3:33 am #675207Alain Aubry
Hi Tom
FOUND! As these CTP’s does not have categories or tags
generate_content_nav()is failing to work.Somewhere else I have:
add_filter( 'generate_category_post_navigation', 'indigo_category_post_navigation' ); function indigo_category_post_navigation() { // return true; return false; }I have it set to true, which works fine with my posts, I switched to false and
generate_content_nav()started to work.So I changed this filter to selectively pass true or false.
add_filter( 'generate_category_post_navigation', 'indigo_category_post_navigation' ); function indigo_category_post_navigation() { $post_types = array( 'colaborador', 'actividade', 'evento' ); if ( in_array( get_post_type(), $post_types ) ) : return false; else : return true; endif; }Also I changed to priority of ‘indigo_cpt_footer_meta’ to 20 to go below other stuff hooked there.
I have to say that your code is very clear and easy to follow.
Thank you so much!
Alain
September 12, 2018 at 9:31 am #675593Tom
Lead DeveloperLead DeveloperAwesome! Glad you got it working 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.