next_post_link() function for posts in the same category does not work

Asked

Viewed 69 times

0

I need to generate a button for the next post in the category and am using the following code

<?php next_post_link('%link','<span class="button-1">%title</span>',TRUE); ?>

But it includes posts from other categories even setting the $in_same_term parameter as TRUE and excluding other categories with the $excluded_terms parameter, modifying these parameters has no effect on the generated link, only the $format and $link parameters work.

I inserted this code into a content-news.php file which is called within the single.php.

  • Have you tried <?php next_post_link( '%link', 'Next post in Category', TRUE, '13' ); ? > replacing the 13 pe id of the category, also try this way but without the id of the category

  • That’s because wordpress is a great XGH user of global.

  • I tried, the link doesn’t appear.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.