简体   繁体   English

链接类别帖子(Wordpress)

[英]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. 我在Wordpress中有一个名为“新闻”的类别,并希望在查看故事时链接到下一个新闻页面。

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 非常感谢

From the WordPress documentation : WordPress文档中

previous_post_link($format, $link, $in_same_cat = false, $excluded_categories = '')

So just add true as a third parameter: 因此,只需将true添加为第三个参数:

<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 -->

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM