Is it possible to force previous/next navigation to browse through the posts (back and forth) that are only inside the same category (and to exclude other categories)?
Is it possible to force previous/next navigation to browse through the posts (back and forth) that are only inside the same category (and to exclude other categories)?
Share Improve this question edited Apr 8, 2012 at 22:41 fuxia♦ 107k39 gold badges255 silver badges459 bronze badges asked Apr 8, 2012 at 17:09 BloglimitsBloglimits 411 silver badge3 bronze badges2 Answers
Reset to default 5The functions accept an $in_same_cat
argument, the default value of which is false. Just set that to true.
previous_post_link($format, $link, true);
next_post_link($format, $link, true);
You can use the following code in single.php loop to display nex/pre links in same category
<?php
get_template_part( 'content', get_post_format() );
// Previous/next post navigation.
previous_post_link('%link', 'Before', true );
next_post_link( '%link', 'Next', true );
?>
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745271837a4619795.html
评论列表(0条)