3

I have single CPT called portfolio. There approx 40 items. half have a category assigned of 'projects', and the other half 'gallery'.

When you are on the single portfolio page, I would like to have post navigation only relate to posts of a certain category.

However when I am at the oldest post of 'Gallery' I can see the previous post link to 'project'.

My code is below.. Am I missing something? thanks

<?php the_post_navigation(array(
                    'prev_text'=>__('previous project: %title'),
                    'next_text'=>__('next project: %title'),
                    'in_same_term' => true,

                )); ?>

1 Answer 1

3

You mention a custom post type, are you also using a custom taxonomy? If so you need to specify this taxonomy in your function call:

the_post_navigation(array(
    'prev_text'=>__('previous project: %title'),
    'next_text'=>__('next project: %title'),
    'in_same_term' => true,
    'taxonomy' => 'wpse240053_custom_taxonomy_name',
));

By default the built-in category taxonomy for Posts is used. This requires WP4.4 or later.

1
  • Thanks for looking, but this is using standard categories and WP is latest version. most odd. Commented Sep 22, 2016 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.