- This topic has 12 replies, 2 voices, and was last updated 2 years, 5 months ago by
Tom.
-
AuthorPosts
-
October 14, 2020 at 5:22 pm #1489453
Mike
Hi,
Having had support for this from your forum to make this change I’ve found it not longer works well after the update.I’m removing the default meta items after a post title, and post footer, and then replacing the meta with the standard items for ‘posts’ and custom meta for my custom post type ‘stories’.
if ‘post’ post-type (single or archive) – put back the standard entries OR if ‘stories’ custom post-type (single or archive) present a completely different set of meta entries in either header or footer.
Since the update to 3.0, standard posts types are presenting two sets of meta entries on each of the header and footer area (three sets of post navigation!) of a post in either single or archive view. Custom post type code works fine.
If you visit the site I put in the private info box, you’ll see the problem. Please note, this was working well before the update.
Can you give me some pointers what’s change in 3.0 that might be causing this? I guess it’s changes to either the standard templates or to the generate_entry_meta() and generate_content_nav{} hooks?
This is done with:
Header meta code:
// // //Take out what GeneratePress was going to do for meta after title // // add_action( 'after_setup_theme','magickgate_remove_meta_after_title' ); function magickgate_remove_meta_after_title() { remove_action( 'generate_after_entry_title', 'generate_post_meta' ); } // // //Add our own function to replace the meta after title // // add_action( 'generate_after_entry_title', 'magickgate_meta_after_title' ); function magickgate_meta_after_title() { // If it's a standard blog archive page, present the meta-after-title: if ( 'post' == get_post_type() && !is_single() ) : ?> <div class="entry-meta"> <!-- Meta on a standard archive page --> <?php generate_posted_on(); ?> </div> <?php endif; // If it's a standard blog single post page, present the meta-after-title: if ( 'post' == get_post_type() && is_single()) : ?> <div class="entry-meta"> <!-- Meta inside a standard post --> <?php generate_posted_on(); ?> </div> <?php endif; // If it's an 'stories' archive page, present the custom 'stories' meta-after-title: if ( 'stories' == get_post_type() && !is_single()) : ?> <div class="entry-meta-stories-after-title"> <!-- Custom meta on a STORIES archive page --> <?php $alias = get_the_term_list(get_the_ID() , 'mg_alias', $before = '', ', '); $writer = get_the_term_list(get_the_ID() , 'mg_writer', $before = '', ', '); $series = get_the_term_list(get_the_ID() , 'mg_series', $before = '', ', '); $pub_date = get_the_date(); if ($alias == '') { $author_string = $writer; } else { $author_string = $alias; } ?> <div class="story-meta-links"> <h3><span><?php echo $pub_date; ?> </span></h3> </div> <div class="story-meta-links"> <h3><span><?php echo $author_string; ?> </span></h3> </div> <div class="story-meta-links"> <p><span><?php echo $series; ?> </span></p> </div> </div> <?php endif; // If it's an 'stories' single item page, present the custom 'stories' meta-after-title for single pages: if ( 'stories' == get_post_type() && is_single()) : ?> <div class="entry-meta-story-after-title"> <!-- Custom meta on an MD single item page --> <?php $alias = get_the_term_list(get_the_ID() , 'mg_alias', $before = '', ', '); $writer = get_the_term_list(get_the_ID() , 'mg_writer', $before = '', ', '); $series = get_the_term_list(get_the_ID() , 'mg_series', $before = '', ', '); $pub_date = get_the_date(); if ($alias == '') { $author_string = $writer; } else { $author_string = $alias; } ?> <div class="story-meta-links"> <h3><span><?php echo $pub_date; ?> </span></h3> </div> <div class="story-meta-links"> <h3><span><?php echo $author_string; ?> </span></h3> </div> <div class="story-meta-links"> <p><span><?php echo $series; ?> </span></p> </div> </div> <?php endif; }
Footer meta code:
// // //Take out what GeneratePress was going to do for meta after content // // add_action( 'after_setup_theme','magickgate_remove_meta_after_content' ); function magickgate_remove_meta_after_content() { remove_action( 'generate_after_entry_content', 'generate_footer_meta' ); } // // // Add our own function to replace the meta after content // // add_action('generate_after_entry_content', 'magickgate_meta_after_content'); function magickgate_meta_after_content() { // If it's a standard blog archive page, present the meta-after-content: if ( 'post' == get_post_type() && !is_single()): ?> <footer class="entry-meta"> <!-- Meta after Content on standard archive page --> <?php generate_entry_meta(); ?> </footer> <?php endif; // If it's a standard blog single post page, present the meta-after-content: if ( 'post' == get_post_type() && is_single()) : ?> <footer class="entry-meta"> <!-- Meta after Content on standard post page --> <?php generate_entry_meta(); generate_content_nav( 'nav-below' ); ?> </footer> <?php endif; // If it's an 'stories' archive page, present the custom 'stories' meta-after-content: if ( 'stories' == get_post_type() && !is_single()) : //Pull the term lists into variables to be displayed later $topic = get_the_term_list(get_the_ID() , 'mg_topic', $before = '', ', '); $setting = get_the_term_list(get_the_ID() , 'mg_setting', $before = '', ', '); $genre = get_the_term_list(get_the_ID() , 'mg_genre', $before = '', ', '); //Build the HTML - noting the new class for the footer in case we want to style differently "entry-meta-story-footer" ?> <footer class="entry-meta"> <!---story-footer Meta after Content on 'story' archive page --> <div class="story-meta-links-footer"> <p></p> <p><span><?php echo 'THEMES: ' . $topic ?> </span></p> <p><span><?php echo 'SETTINGS: ' . $setting ?> </span></p> <p><span><?php echo 'GENRE: ' . $genre ?> </span></p> </div> </footer> <?php endif; // If it's an 'stories' single item page, present the custom 'stories' meta-after-content for single pages: if ( 'stories' == get_post_type() && is_single()) : //Pull the term lists into variables to be displayed later $topic = get_the_term_list(get_the_ID() , 'mg_topic', $before = '', ', '); $setting = get_the_term_list(get_the_ID() , 'mg_setting', $before = '', ', '); //Build the HTML - noting the new class for the footer in case we want to style differently "entry-meta-cpt-footer" ?> <footer class="entry-meta"> <!-- Meta after Content on 'stories' single page --> <div class="story-meta-links-footer"> <p></p> <p><span><?php echo 'THEMES: ' . $topic ?> </span></p> <p><span><?php echo 'SETTINGS: ' . $setting ?> </span></p> <p><span><?php echo 'GENRE: ' . $genre ?> </span></p> </div> <?php generate_content_nav( 'nav-below' ); ?> </footer> <?php endif; }
October 14, 2020 at 8:10 pm #1489543Tom
Lead DeveloperLead DeveloperHi there,
Instead of
after_setup_theme
, trywp
.For example:
add_action( 'wp', 'magickgate_remove_meta_after_title' ); function magickgate_remove_meta_after_title() { remove_action( 'generate_after_entry_title', 'generate_post_meta' ); } add_action( 'wp','magickgate_remove_meta_after_content' ); function magickgate_remove_meta_after_content() { remove_action( 'generate_after_entry_content', 'generate_footer_meta' ); }
Let us know ๐
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentOctober 15, 2020 at 8:21 am #1490639Mike
Hi Tom,
so that worked – I wonder if you could explain briefly what the change meant? The only problem was that there was still a duplicate of the post navigation for the standard post type.
It’s a bit weird. Presence of a second set of entries / control using customizer of the meta for the custom post type isn’t working. So I can leave “Show post navigation” turned off, and the “nav-below” in the code here puts it back in. I’m just curious what changed and wonder if you could explain?
thank you for all your help!
Mike// If it's a standard blog single post page, present the meta-after-content: if ( 'post' == get_post_type() && is_single()) : ?> <footer class="entry-meta"> <!-- Meta after Content on standard post page --> <?php generate_entry_meta(); generate_content_nav( 'nav-below' ); ?> </footer> <?php endif;
October 15, 2020 at 9:49 am #1490776Tom
Lead DeveloperLead DeveloperYes, you can remove this from your code:
generate_content_nav( 'nav-below' );
The
wp
is necessary as we’re using that hook now to add the items to your page. This allowed us more flexibility for a post meta ordering feature we’re working on.Same with the above code – the post navigation was added to the post meta ordering system, so the function isn’t necessary anymore.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentOctober 15, 2020 at 7:03 pm #1491260Mike
Thanks!
October 15, 2020 at 7:18 pm #1491268Mike
Sorry Tom, one further question. Why is the generate_content_nav( ‘nav-below’ ); still necessary in the case of my custom post type?
I’ve removed this code from my standard post-type meta, and re-enabled display of post navigation on the single post view in customizer.
However on my custom post-type “stories” it’s still required.
Based on what you’ve said, I think that’s because the “generate_post_meta” functionality now also includes the content navigation? And I’ve removed that in my code, so now the navigation has gone away with it?
Thanks for your time helping me understand this, it’s much appreciated.
Mike
October 16, 2020 at 9:42 am #1492276Tom
Lead DeveloperLead DeveloperYou’ll just need to tell GP to include footer post meta on your post type:
add_filter( 'generate_footer_meta_post_types', function( $types ) { $types[] = 'your-post-type'; return $types; } );
Let me know if that helps or not ๐
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentOctober 16, 2020 at 4:24 pm #1492638Mike
Hi Tom,
adding that filter doesn’t seem to provide the post navigation on the custom post type at all, and the following is still needed, even when post navigation is turned on in customizer.
generate_content_nav( 'nav-below' );
I’ve tried using the slug (‘stories’) and the cpt name which is specified as (‘Stories’) and it still doesn’t add the navigation for the CPT.
Thoughts?
Mike
October 17, 2020 at 11:17 am #1493505Tom
Lead DeveloperLead DeveloperCan you link me to one of the posts in that post type, and share the exact code you’re using?
Thanks!
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentOctober 17, 2020 at 1:25 pm #1493609Mike
Hi Tom,
Thank you! Link is in the private field.
Code here:
// // //Take out what GeneratePress was going to do for meta after content // // add_action( 'wp','magickgate_remove_meta_after_content' ); function magickgate_remove_meta_after_content() { remove_action( 'generate_after_entry_content', 'generate_footer_meta' ); } // // // Add our own function to replace the meta after content // // add_action('generate_after_entry_content', 'magickgate_meta_after_content'); function magickgate_meta_after_content() { add_filter( 'generate_footer_meta_post_types', function( $types ) { $types[] = 'stories'; return $types; } ); // If it's a standard blog archive page, present the meta-after-content: if ( 'post' == get_post_type() && !is_single()): ?> <footer class="entry-meta"> <!-- Meta after Content on standard archive page --> <?php generate_entry_meta(); ?> </footer> <?php endif; // If it's a standard blog single post page, present the meta-after-content: if ( 'post' == get_post_type() && is_single()) : ?> <footer class="entry-meta"> <!-- Meta after Content on standard post page --> <?php generate_entry_meta(); // NO LONGER REQUIRED: generate_content_nav( 'nav-below' ); ?> </footer> <?php endif; // If it's an 'stories' archive page, present the custom 'stories' meta-after-content: if ( 'stories' == get_post_type() && !is_single()) : //Pull the term lists into variables to be displayed later $topic = get_the_term_list(get_the_ID() , 'mg_topic', $before = '', ', '); $setting = get_the_term_list(get_the_ID() , 'mg_setting', $before = '', ', '); $genre = get_the_term_list(get_the_ID() , 'mg_genre', $before = '', ', '); $series = get_the_term_list(get_the_ID() , 'mg_series', $before = '', ', '); $format = get_the_term_list(get_the_ID() , 'mg_format', $before = '', ', '); //Build the HTML - noting the new class for the footer in case we want to style differently "entry-meta-story-footer" ?> <footer class="entry-meta"> <!---story-footer Meta after Content on 'story' archive page --> <div class="story-meta-links-footer"> <p></p> <p><span><?php echo 'SERIES: ' . $series ?> </span></p> <p><span><?php echo 'THEMES: ' . $topic ?> </span></p> <p><span><?php echo 'SETTINGS: ' . $setting ?> </span></p> <p><span><?php echo 'GENRE: ' . $genre ?> </span></p> <p><span><?php echo 'FORMAT: ' . $format ?> </span></p> </div> </footer> <?php endif; // If it's an 'stories' single item page, present the custom 'stories' meta-after-content for single pages: if ( 'stories' == get_post_type() && is_single()) : //Pull the term lists into variables to be displayed later $topic = get_the_term_list(get_the_ID() , 'mg_topic', $before = '', ', '); $setting = get_the_term_list(get_the_ID() , 'mg_setting', $before = '', ', '); $genre = get_the_term_list(get_the_ID() , 'mg_genre', $before = '', ', '); $series = get_the_term_list(get_the_ID() , 'mg_series', $before = '', ', '); $format = get_the_term_list(get_the_ID() , 'mg_format', $before = '', ', '); //Build the HTML - noting the new class for the footer in case we want to style differently "entry-meta-cpt-footer" ?> <footer class="entry-meta"> <!-- Meta after Content on 'stories' single page --> <div class="story-meta-links-footer"> <p></p> <p><span><?php echo 'SERIES: ' . $series ?> </span></p> <p><span><?php echo 'THEMES: ' . $topic ?> </span></p> <p><span><?php echo 'SETTINGS: ' . $setting ?> </span></p> <p><span><?php echo 'GENRE: ' . $genre ?> </span></p> <p><span><?php echo 'FORMAT: ' . $format ?> </span></p> </div> <?php // no longer required - but if I remove this code we get no navigation: generate_content_nav( 'nav-below' ); ?> </footer> <?php endif; }
October 18, 2020 at 12:16 pm #1494685Tom
Lead DeveloperLead DeveloperYou’ve removed
generate_footer_meta()
:remove_action( 'generate_after_entry_content', 'generate_footer_meta' );
But you haven’t re-added it anywhere.
If you’re not going to re-add it, you need to manually add
generate_content_nav( 'nav-below' );
in your functions where you’ve added other post meta.Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentOctober 18, 2020 at 7:18 pm #1494899Mike
Hi Tom,
what’s confusing me is that yes, I have removed the standard generation of Meta after content.
And then added my own function, which will generate the after content meta for:
“posts” either archive or single view
“stories” either archive or single viewIn each single view case I need the navigation.
For “posts” I no longer need to specifygenerate_content_nav( 'nav-below' );
yet the navigation appears.Why then do I need to still specify it in for the single view of the “stories” post type?
I’m sure I’m missing something. BEFORE these changes, I needed to specify it in both places. Sorry if I’m missing something obvious!
thanks
MikeOctober 19, 2020 at 9:51 am #1495876Tom
Lead DeveloperLead DeveloperI’m not really sure, it’s hard to tell by your code. That function must still be present for single posts, but not for other post types.
You would have to remove your custom functions one by one to see which one is removing it for stories.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.