Show posts of one category only with Custom Taxonomy on single.php

Since I’m not sure if you are using single.php for anything else, I am going to suggest that you copy single.php to single-14kgs.php in the theme directory.

Once you have done that, modify the following:

<?php next_posts_link(); ?>

becomes…

<?php next_post_link('%link','%title',TRUE) ?>

and

<?php previous_posts_link(); ?>

becomes…

<?php previous_post_link('%link', '%title', TRUE); ?>

The third argument to those functions tells WP to generate a link and stay in the same category.

For further reading:

https://codex.wordpress.org/Function_Reference/previous_post_link
https://codex.wordpress.org/Function_Reference/next_post_link

Leave a Comment