The Codex disagrees with itself, so I'm stumped.
On single.php
I am trying to use next_post_link()
to display a link to the next post, with custom link text, within the same category as the current post.
The Codex article on next_post_link()
says the parameters are $format, $link, $in_same_term, $excluded_terms, and $taxonomy. Its specific example for my scenario is
<?php next_post_link( '%link', 'Next post in category', TRUE ); ?>
But when I use that exact code, no link is output at all. The rest of the Post fully renders, it's just missing the next post link HTML completely.
If I take out just the "TRUE" it outputs a link almost as desired:
<?php next_post_link( '%link', 'Next post in category' ); ?>
But it links to the next Post in any category, and I need to restrict it to the current category.
The Codex article on Next and Previous Links contradicts the article specifically on next_post_link()
. It says the parameters are $format, $text, and $title. That would mean that you can't restrict the link to posts within the current category. Since the Code Reference on next_post_link()
matches the Codex on next_post_link()
that seems likely to be the most accurate.