- This topic has 39 replies, 3 voices, and was last updated 5 years, 6 months ago by
Tom.
-
AuthorPosts
-
September 21, 2020 at 12:00 pm #1452760
Michael
Oh and also the thumbnails on the CPT posts are taken from the current CPT.
See link
September 21, 2020 at 2:08 pm #1452939Tom
Lead DeveloperLead DeveloperYou should just be able to do this for everything:
add_filter( 'generate_post_navigation_args', function( $args ) { if ( is_single() ) { $prevPost = get_previous_post( true, '', 'wpdmcategory' ); $prevThumbnail = isset( $prevPost ) ? get_the_post_thumbnail( $prevPost->ID ) : ''; $nextPost = get_next_post( true, '', 'wpdmcategory' ); $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>'; } if ( is_singular( 'wpdmpro' ) ) { $args['taxonomy'] = 'wpdmcategory'; $args['in_same_term'] = true; } return $args; } ); add_filter( 'generate_footer_meta_post_types', function( $types ) { $types[] = 'wpdmpro'; return $types; } );This should:
1. Add thumbnails to your post navigation if they exist.
2. Set thewpdmcategorytaxonomy in yourwpdmpropost type, and make it so the post navigation stays within the current term.
3. Tells GeneratePress to add footer post meta to your custom post type.September 22, 2020 at 5:15 am #1453656Michael
Hi Tom, pleased to say that it does indeed work. I had to enable the stay in category function as it wasn’t doing that. Also even with that running the CPT doesn’t stick to same category. Additionally the CPT thumbnails for next and previous are showing as the current CPT thumbnail on either side.
Have to say it looks great, just need to get these little niggles sorted. Again, appreciate the support here, am hoping it might be useful for anyone else with a similar problem.
September 22, 2020 at 9:38 am #1454144Tom
Lead DeveloperLead DeveloperAwesome! I’m sure it’ll be helpful to others 🙂
September 23, 2020 at 5:34 am #1455226Michael
I’m sure it will 🙂 , how can I fix the same thumbnail issue for the CPT ? uses the same thumb for next and previous, and the thumb it uses is that of the current post (download in this case) ?
September 23, 2020 at 10:05 am #1455786Tom
Lead DeveloperLead DeveloperIs there a specific link where I can see that happening?
September 23, 2020 at 10:10 am #1455795Michael
Hi Tom, examples in the private information area. Also CPT are showing from different categories also.
September 23, 2020 at 3:29 pm #1456117Tom
Lead DeveloperLead DeveloperSeptember 24, 2020 at 3:43 am #1456677Michael
Brilliant, thank you so so much! The CPT aren’t staying within category, but I won’t bother you anymore. I know you’ll be fed up of this. 🙂
I’ll see if I can try different things to get that to work. Really appreciate all your work on this Tom. Just wish I knew more. I do try though.
September 24, 2020 at 9:33 am #1457299Tom
Lead DeveloperLead DeveloperBest thing to do there is look into the taxonomy name. If the name is correct,
in_same_termshould work fine. -
AuthorPosts
- You must be logged in to reply to this topic.