views:

11

answers:

1

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 previous"><?php previous_post_link('%link') ?></div>
<div class="button next"><?php next_post_link('%link') ?></div>
   </div><!-- page-navi -->

Many thanks

+1  A: 

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 -->
Kau-Boy
Sweet that works well, thank you :)
Rob