本页目录
来源于:
https://blog.wpjam.com/m/WordPress-next-previous-post-permalink-title-thumbnail/

涉及到 WordPress 函数标签
实现代码
<div class="post-PrevNext"> <?php $current_category = get_the_category();//获取当前文章所属分类ID $prev_post = get_previous_post($current_category,'');//与当前文章同分类的上一篇文章 $next_post = get_next_post($current_category,'');//与当前文章同分类的下一篇文章 ?> <div class="previous_post_link"> <?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; ?> </div> <div class="next_post_link"> <?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; ?> </div></div>统一图像高度、宽度:
.previous_post_link,.next_post_link,img{ width: 420px; height: 230px;}