- This topic has 39 replies, 3 voices, and was last updated 4 months ago by
Tom.
-
AuthorPosts
-
September 18, 2020 at 2:39 pm #1449292
Michael
Can’t seem to find a solution by searching here in the forum, I have the next/previous links added, and styled as per instructions found here. The previous post in a category is showing as something that may be being fetched alphabetically from another category? Am terrible at trying to explain things.
Is there a way to control the next and previous so that it works within same categories only, and for custom post categories also? Would much rather do this within the theme than try some additional plugin.
Thanks as always.
September 18, 2020 at 2:41 pm #1449294Leo
StaffCustomer SupportHi there,
Is this what you are looking for?
https://docs.generatepress.com/article/generate_category_post_navigation/Let me know 🙂
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/September 19, 2020 at 7:43 am #1449887Michael
Hi Leo, thank you, yes that was what I was looking for, however it doesn’t work with custom post categories. How would I go about getting it to do that ?
September 19, 2020 at 7:45 am #1449888Michael
Have posted a link to show where I mean, it’s the WP Download Manager custom posts..
September 19, 2020 at 9:50 am #1450137Leo
StaffCustomer SupportAre you saying that the post navigation doesn’t show for that CPT or the category post navigation isn’t working in CPT?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/September 19, 2020 at 9:52 am #1450144Michael
Post navigation not showing for that CPT, category post nav working well in standard post type.
September 19, 2020 at 10:52 am #1450203Leo
StaffCustomer SupportTry this:
https://generatepress.com/forums/topic/displaying-posts-navigation-on-cpts/Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/September 19, 2020 at 11:58 am #1450258Michael
Don’t seem to be getting anywhere with that, I’m getting the meta output, but no navigation.
add_action( 'generate_after_entry_content', 'tu_cpt_footer_meta' ); function tu_cpt_footer_meta() { if ( is_singular( 'wpdmpro' ) ) : ?> <footer class="entry-meta"> <?php generate_entry_meta(); ?> <?php generate_content_nav( 'nav-below' ); ?> </footer><!-- .entry-meta --> <?php endif; }
Is what I tried from the link you posted, replacing the custom post type name.
The code I’m using for the other navigation is..
add_filter( 'generate_post_navigation_args', function( $args ) { if ( is_single() ) { $prevPost = get_previous_post(true); $prevThumbnail = isset( $prevPost ) ? get_the_post_thumbnail( $prevPost->ID ) : ''; $nextPost = get_next_post(true); $nextThumbnail = isset( $nextPost ) ? get_the_post_thumbnail( $nextPost->ID ) : ''; $args['previous_format'] = '<div class="nav-previous">' . $prevThumbnail . generate_get_svg_icon( 'arrow' ) . '<span class="prev" title="' . esc_attr__( 'Previous', 'generatepress' ) . '">%link</span></div>'; $args['next_format'] = '<div class="nav-next">' . $nextThumbnail . generate_get_svg_icon( 'arrow' ) . '<span class="next" title="' . esc_attr__( 'Next', 'generatepress' ) . '">%link</span></div>'; } return $args; } );
Could I not modify the if is single line to include OR and the custom post type? It’s a bit over my head the code structure, am just theorising.
I checked with download manager and that seems to be the way things are checked, from one of their forum posts
if ( is_singular( 'wpdmpro' ) ) {
September 19, 2020 at 5:42 pm #1450425Leo
StaffCustomer SupportSorry where did the second function come from?
Can we try one at the time?
Did you make sure to clear the caching plugin after adding that first block of code?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/September 20, 2020 at 7:35 am #1450963Michael
The second function came from the these forums for post nav with thumbnails, they work. The first function came from me trying to add another function, to handle the CPT from the post you pointed me to, which just outputs the meta for that post.
I thought (hoped) that the first function could possibly be modified to check for the CPT, so that there was just one function.
I did clear the cache also, but still just delivers the meta.
September 20, 2020 at 9:20 am #1451177Leo
StaffCustomer SupportDoes the first function work without the second one?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/September 20, 2020 at 9:25 am #1451184Michael
The first works with or without the second, but it’s just outputting tags no nav..
Ideally, for UX would like to keep the same layout across all.
September 20, 2020 at 9:26 am #1451186Tom
Lead DeveloperLead DeveloperStrange, is the custom post type using a custom taxonomy?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentSeptember 20, 2020 at 9:27 am #1451187Michael
It’s confusing, as far as I can tell it uses categories as the name for their taxonomy, but it’s separate from the normal post categories taxonomies.
September 20, 2020 at 9:33 am #1451200Tom
Lead DeveloperLead DeveloperIf it’s not the core
category
taxonomy, you may need to do this:add_filter( 'generate_post_navigation_args', function( $args ) { if ( is_singular( 'wpdmpro' ) ) { $args['taxonomy'] = 'the_taxonomy_slug'; } return $args; } );
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.