- This topic has 39 replies, 3 voices, and was last updated 3 years, 6 months ago by Tom.
-
AuthorPosts
-
September 20, 2020 at 9:43 am #1451218Michael
Ok.. bordering on out of my depth, but after looking into it.. I found the category for the CPT is wpdmcategory
So I tried..
add_filter( 'generate_post_navigation_args', function( $args ) { if ( is_singular( 'wpdmpro' ) ) { $args['taxonomy'] = 'wpdmcategory'; } return $args; } );
No output, did I do this correctly ?
September 20, 2020 at 9:44 am #1451222TomLead DeveloperLead DeveloperThat’s the custom taxonomy name?
Can you post the full set of functions (related to this) that you’re using now?
September 20, 2020 at 9:46 am #1451228Michaeladd_filter( 'generate_post_navigation_args', function( $args ) { if ( is_singular( 'wpdmpro' ) ) { $args['taxonomy'] = 'wpdmcategory'; } return $args; } );
And the one to stay in category
add_filter( 'generate_category_post_navigation', 'mike_stay_category' ); function mike_stay_category() { return 'true'; }
The other one for the normal nav with the thumbnails is disabled.
September 20, 2020 at 9:48 am #1451231TomLead DeveloperLead DeveloperSo instead of those two, try this:
add_filter( 'generate_post_navigation_args', function( $args ) { if ( is_singular( 'wpdmpro' ) ) { $args['taxonomy'] = 'wpdmcategory'; $args['in_same_term'] = true; } return $args; } );
So this is telling the post navigation to only display links in the same term within that custom taxonomy. It will only work if that taxonomy name is correct and if other posts exist in the same term.
Out of curiosity, does the post navigation display without same term stuff?
September 20, 2020 at 9:55 am #1451245MichaelNothing displaying there with or without the same terms stuff. It is strange this.
I’ve looked on their support for anything relating to next previous, and all I can find is where they disable it for someone, by creating a custom single.php and removing the nav code. They then rename it to wpdm-single.php which it must look for in terms of customisation. Implies nav must be standard ?
Am flummoxed.
September 20, 2020 at 9:55 am #1451246MichaelIf you want a login, I can send one if you want to see if you can spot anything ?
September 20, 2020 at 9:59 am #1451251TomLead DeveloperLead DeveloperYou’ll need this as well to tell GeneratePress to include the post meta on the CPT:
add_filter( 'generate_footer_meta_post_types', function( $types ) { $types[] = 'wpdmpro'; return $types; } );
Anything happen with the above code only added (other functions commented out)?
September 20, 2020 at 10:02 am #1451255MichaelYes !!
Am now getting navigation (and tags) , but not in the same category by the looks of things.
September 20, 2020 at 10:03 am #1451257TomLead DeveloperLead DeveloperNow add this:
add_filter( 'generate_post_navigation_args', function( $args ) { if ( is_singular( 'wpdmpro' ) ) { $args['taxonomy'] = 'wpdmcategory'; $args['in_same_term'] = true; } return $args; } );
September 20, 2020 at 10:07 am #1451265MichaelLooking good, I didn’t know whether to delete the other one, but I just added this.. I have the previous and next in same category, but seem to be the wrong way round.. ie the one on the right is the previous one on the list. I can live with that .. can I get thumbs .. and I know asking a lot, just a title central above them to indicate to user what these links are. Or even just some text saying previous next download (as well as titles).
Tom, this is excellent, thank you so much.
September 20, 2020 at 10:08 am #1451266MichaelOh forgot, can I enable the function for the regular posts alongside this as well now (currently disabled)
September 20, 2020 at 5:32 pm #1451510TomLead DeveloperLead DeveloperThis code you shared last page should add thumbs:
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; } );
How are they turned on on single posts right now?
September 21, 2020 at 1:39 am #1451799MichaelThanks, that got the thumbnail nav back to the regular posts, but they disappeared from the CPT. The post navigation is turned on via the customiser settings.
September 21, 2020 at 10:41 am #1452665TomLead DeveloperLead DeveloperThe code above removed the post navigation from the CPT completely?
September 21, 2020 at 11:52 am #1452742MichaelHi Tom,
Am getting confused.. there were 4 functions..
The keep in category one enabled
The first and second CPT functions you posted.
The thumbnail function.
I thought the second CPT one you sent was to be used instead of the first CPT one you sent, so I disabled the first function. That stopped the output at the CPT areas. After enabling both CPT functions I now get back the post nav in the custom post area (with thumbs) but they’re from different categories.
I wasn’t sure which CPT function I had to keep, so now they’re both active. almost there with this .. just need a way to keep the CPT to the same category, and if possible add some kind of text above the previous and next to indicate that’s what they are at a glance (if possible). Am sure I could write add a hook or something, but would make more sense (lighter) if that was included with the next/previous function.
Appreciate your work on this, didn’t realise it was going to be so tricky.
-
AuthorPosts
- You must be logged in to reply to this topic.