wordpress上下篇

2018-06-22 05:32:56来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

 

分页一:

<!--上下篇开始-->
<div class="shangxia">
<?php
  $current_category=get_the_category();
  $prev_post = get_previous_post($current_category,'');
  $next_post = get_next_post($current_category,'');
?>
<?php if (!empty( $prev_post )): ?>
  <a href="<?php echo get_permalink( $prev_post->ID ); ?>" title="上一篇:<?php echo $prev_post->post_title; ?>">上一篇:<?php echo $prev_post->post_title; ?></a>
<?php else : ?>
  <a title="已经是第一篇了">已经是第一篇了</a>
<?php endif; ?>
<!--上下片分离-->
<?php if (!empty( $next_post )): ?>
  <a href="<?php echo get_permalink( $next_post->ID ); ?>" title="下一篇:<?php echo $next_post->post_title; ?>">下一篇:<?php echo $next_post->post_title; ?></a>
<?php else : ?>
  <a title="已经是最后一篇了">已经是最后一篇了</a>
<?php endif; ?>
</div>
<!--上下篇结束-->

 

 

分页二:

<?php
$categories = get_the_category();
$categoryIDS = array();
foreach ($categories as $category) {
array_push($categoryIDS, $category->term_id);
}
$categoryIDS = implode(",", $categoryIDS);
?>                
<div class="post-blockE">
    <div class="post-previous">
        <?php if (get_previous_post($categoryIDS)) { previous_post_link('<span>上一篇:</span> %link');} else {echo "没有了,已经是最后文章";} ?>
    </div>
    <div class="post-next">
        <?php if (get_next_post($categoryIDS)) { next_post_link('<span>下一篇:</span> %link');} else {echo "没有了,已经是最新文章";} ?>
    </div>
</div>    

 

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:PHP数组

下一篇:PHP小程序,子网掩码长度的计算