Linking category posts (Wordpress)
I have a category in Wordpress called News and would like to link to the next news page when viewing a story.
This is the existing code but will link to all posts, what should I add to make it just posts in the News category?
<div id="page-navi">
<div class="button previ开发者_StackOverflow社区ous"><?php previous_post_link('%link') ?></div>
<div class="button next"><?php next_post_link('%link') ?></div>
</div><!-- page-navi -->
Many thanks
From the WordPress documentation:
previous_post_link($format, $link, $in_same_cat = false, $excluded_categories = '')
So just add true
as a third parameter:
<div id="page-navi">
<div class="button previous"><? previous_post_link('%link', 'Previous in category', true) ?></div>
<div class="button next"><?php next_post_link('%link', 'Next in category', true) ?></div>
</div><!-- page-navi -->
精彩评论