wordpress上下篇

 

分頁一:php

<!--上下篇開始-->
<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>
<!--上下篇結束-->

 

 

分頁二:post

<?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>    
相關文章
相關標籤/搜索