0
因此,我修改了single-news.php文件以获取上一个/下一个按钮来浏览新闻,但该代码使用了帖子ID,例如im在属于类别1的post1中,我按下“下一个”它不一定会在同一类别中进入下一篇文章。Wordpress获取上一个/下一个按钮,使用文章中的类别
<?php
if (is_single()):
$prev = get_previous_post_link();
$prev = str_replace('«', '<div class="wrapper"><span class="fa fa-angle-left"></span>', $prev);
$prev = str_replace('</a>', '</a></div>', $prev);
$next = get_next_post_link();
$next = str_replace('»', '<span class="fa fa-angle-right"></span></div>', $next);
$next = str_replace('<a', '<div class="wrapper"><a', $next);
?>
<div class="shapely-next-prev row">
<div class="col-xs-6 text-left" >
<?php echo wp_kses_post($prev) ?>
</div>
<div class="col-xs-6 text-right">
<?php echo wp_kses_post($next) ?>
</div>
</div>
关于如何修改此代码的任何想法?我已经看到这已被问了很多次,但我无法实现这些帖子的想法。
我已经试过了,但它doenst显示任何东西:
$next = next_post_link($format, $link, $in_same_term = true, $excluded_terms = '', $taxonomy = 'category');
也为我使用Wp的新闻消息和滚动部件
编辑: 当我使用这个我有结果为相同现在
$next = get_next_post_link('« %link', '%title', FALSE);
但是当我这样使用它是不显示任何东西:
$next = get_next_post_link('« %link', '%title', TRUE);