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

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.

Leave a Reply

Your email address will not be published. Required fields are marked *