Support » Plugin: Previous and Next Post in Same Taxonomy » [Plugin: Previous and Next Post in Same Taxonomy] Can't get link to next post in same taxonomy

Viewing 9 replies - 1 through 9 (of 9 total)
  • By default, the taxonomy it uses is ‘category’. It seems your last two examples would work for any category and your first example would work for any category except ‘case-study’.

    Are you wanting to navigate by custom taxonomy or post tags?

    be_next_post_link( $format='%link »', $link='%title', $in_same_cat = false, $excluded_categories = '', $taxonomy = 'category')

    Christine Rondeau


    Volunteer Forum Moderator

    I would like to navigate to the next case study.
    My custom post type is client and I’ve created a taxonomy called client-type. Only the ones marked as case-studies are clickable and lead to the single-client.php template.

    So when you are on this page – and click the first client, once in there, you can then navigate to the next one.

    If I just use <?php next_post_link( ‘%link’, ‘See Next Case Study’);?> I get the next client, but not necessarily the one that is in the case-study taxonomy.

    Got it. It seems like the correct syntax should then be:

    be_next_post_link( '%link', 'See Next Case Study, true, '', 'client-type' );

    That looks for the next post link by staying in the same ‘cat’ (badly named argument) and by using the ‘client-type’ taxonomy.

    Christine Rondeau


    Volunteer Forum Moderator

    bah, that didn’t work.

    The link shows up, but then it also displays links to other clients that are not in the case study taxonomy.

    I think I may have to go with just back to case studies.

    I’ve left the code – <?php be_next_post_link( '%link', 'See Next Case Study', true, '', 'client-type' ); ?> in there if you want to see what it looks like Jeremy, you’ll see if you click away, you’ll get to clients that don’t have a case study.

    Close. 🙂

    Do ‘client’ post types have more than one ‘client-type’ assigned to them? I.e. Case Study and Retail & Hospitality

    If that was the case, even though it’s staying in the same taxonomy, it may be picking up the wrong ‘client-type’ as the one to stay inside. I haven’t read through the code enough to know for sure, but it seems possible.

    If that is the case, you could exclude all of the other ‘client-type’ terms by their IDs:

    be_next_post_link( '%link', 'See Next Case Study', true, '5,6,7', 'client-type' );

    … where term IDs 5,6,7 are associated with a client-type that is not a case study. That would be a little more annoying to manage, but could get you there.

    Christine Rondeau


    Volunteer Forum Moderator

    Yes the clients are in more than one taxonomy, so the Canadian Cancer Society is in the case study and non-profit taxonomy.

    I wonder if there’s complication in this because I’m also using a plugin to create my CPT and taxonomies –

    I just tried adding the numbers of the other client types and still no joy.

    From what I’m reading in the prev/next plugin’s code, that last try should be exactly what you need.

    I think using @jkudish‘s plugin to create the CPT and taxonomies is fine as long as ‘client-type’ is the right slug used to register the taxonomy.

    If there are any other plugins installed that could be using the get_{$adjacent}_join or other related filters, then that could change something.

    Seems like we need to get the patch working in core for real.

    Christine Rondeau


    Volunteer Forum Moderator

    I think that your right. Something in my code must be throwing this off. Since the rest of the site works, I think I’ll just make do with the go back button for now and will look at this again alter. I’ll mark this as resolved even though it’s not for me, but it’s not the plugin that’s causing the error. Thanks for your help Jeremy.

    Same behavior here…

    I have a custom post type, let’s call it “chapters” and a custom taxonomy called “book_category”. Chapters are grouped by by unique “book_category”.

    Using something like this in single-book.php (my single post template) inside a standard loop (no custom query or anything):

    <?php be_next_post_link('%link','%title',true,'','book_category'); ?>

    Gives me either no links, or links that point into other seemingly random chapters in other book_category categories.

    Is the plugin still current for 3.5.1?

    This behavior seems to be the same thing I’m seeing with the stock “next_post_link”.

    Oops, forgot to include this, I’m dumping some stuff for troubleshooting:

    echo get_post_type( $post );
    echo "/" . $post->ID;
    $foo = get_the_terms($post->ID, 'book_category');

    The output of that looks like so:

    post type/ID/cat: book/831Array ( [88] => stdClass Object ( [term_id] => 88 [name] => The Challenge to Psychoanalysis and Psychotherapy [slug] => the-challenge-to-psychoanalysis-and-psychotherapy [term_group] => 0 [term_taxonomy_id] => 48 [taxonomy] => book_category [description] => [parent] => 0 [count] => 49 [object_id] => 831 ) )

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Plugin: Previous and Next Post in Same Taxonomy] Can't get link to next post in same taxonomy’ is closed to new replies.