脚本宝典收集整理的这篇文章主要介绍了php – WordPress next_post_link / previous_post_link不保持在同一类别,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
single.PHP中
<?PHP if ( in_category( 'my-category' ) ) { include( TEMPLATEPATH.'/single-my-category.PHP' ); } else { include( TEMPLATEPATH.'/single-generic.PHP' ); } ?>
单我-category.PHP
<?PHP if ( have_posts() ) : while (have_posts()) : the_post(); ?> <?PHP echo the_tITle(); ?> <div class="pagination"> <div class="container"> <div class="row"> <div class="next col-xs-6 col-sm-6 col-md-6 col-lg-6"> <?PHP next_post_link( '%link','<img src="' . get_template_directory_uri() . '/img/cs-left.png" /> PrevIoUS',true ); ?> </div> <div class="PRevIoUs col-xs-6 col-sm-6 col-md-6 col-lg-6"> <?PHP prevIoUs_post_link( '%link','NEXT <img src="' . get_template_directory_uri() . '/img/cs-right.png" />',true ); ?> </div> </div> </div> </div> <?PHP endwhile; endif; ?>
这就是我所追踪的 – http://codex.wordpress.org/Function_Reference/next_post_link
我不太清楚我在这里做错了什么,因为某些原因,即使函数的in_same_term参数设置为true,prevIoUs_post_link也会将我转到不同类别的帖子.
有任何想法吗?
谢谢.
single.PHP中
<?PHP $the_query = new WP_Query( $post ); if (in_category('PHP')) { include( 'template-parts/single-my-category.PHP' ); } else { include( 'template-parts/single-generic.PHP' ); } ?>
单我-category.PHP
if ( have_posts() ) : while (have_posts() ) : the_post(); ?> <?PHP the_title(); ?> <div class="pagination"> <div class="container"> <div class="row"> <div class="next col-xs-6 col-sm-6 col-md-6 col-lg-6"> <?PHP next_post_link( '%link',true ); ?> </div> </div> </div> </div> <?PHP endwhile; endif; ?>
以上是脚本宝典为你收集整理的php – WordPress next_post_link / previous_post_link不保持在同一类别全部内容,希望文章能够帮你解决php – WordPress next_post_link / previous_post_link不保持在同一类别所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。