WordPress获取上下篇的标题

修改single.php文件即可,代码如下:

<nav id=”nav-above” class=”post-navigation clearfix columns twelve”>

 <?php
  $current_category=get_the_category();
  $prev_post = get_previous_post($current_category,”);
  $next_post = get_next_post($current_category,”);
 ?>

 <div class=”nav-previous alignleft”><strong>
  <?php if (!empty( $prev_post )): ?>
  <a href=”<?php echo get_permalink( $prev_post->ID ); ?>”><?php echo get_the_post_thumbnail( $prev_post->ID, ”, ” ); ?></a> 前一篇: <a href=”<?php echo get_permalink( $prev_post->ID ); ?>”><?php echo $prev_post->post_title; ?></a>
  <?php endif; ?></strong>
 </div>
 <div class=”nav-next alignright”><strong>
  <?php if (!empty( $next_post )): ?>
  <a href=”<?php echo get_permalink( $next_post->ID ); ?>”><?php echo get_the_post_thumbnail( $next_post->ID, ”, ” ); ?></a> 后一篇: <a href=”<?php echo get_permalink( $next_post->ID ); ?>”><?php echo $next_post->post_title; ?></a>
  <?php endif; ?></strong>
 </div>

</nav><!– #nav-above –>

本文经过编辑,原地址:http://xiedexu.cn/wordpress-next-previous_post-permalink-title-thumbnail.htm

广而告之
企业建站、官网建设、独立站
真皮手套手套工厂批发零售直销

发表评论