As the title: is there a way to navigate between posts of the same subcategory using the previous_post_link
and next_post_link
functions? But maintaining however both the category and the sub-category of the post.
As the title: is there a way to navigate between posts of the same subcategory using the previous_post_link
and next_post_link
functions? But maintaining however both the category and the sub-category of the post.
If you’ll take a look at next_post_link
Codex page, you’ll see it’s usage:
<?php
next_post_link(
$format,
$link,
$in_same_term = false,
$excluded_terms = '',
$taxonomy = 'category'
);
As you can see, third param is in_same_term
and it’s default value is false. If you set it to true, then the function will return next post from same category. (If you want the term from different taxonomy, you can change fifth param).
So answering your question... Yes, there is a way to achieve this. It can look like so:
<?php next_post_link( '%link »', '%title', true ); ?>