如果你看看next_post_link
您将看到它需要一个参数$link
作为第二个参数:
next_post_link( $format, $link, $in_same_term = false, $excluded_terms = \'\', $taxonomy = \'category\' );
您的参数当前不包括帖子缩略图:
_x( \'%title <span class="meta-nav">→</span>\', \'Next post link\', \'nicosite\' )
所以我们需要这样添加:
$nextPost = get_next_post(true); // You are aware that this only checks for next posts in the same term, right?
if(!empty($nextPost) ){ //This is to check if there is a next post
$nextthumbnail = get_the_post_thumbnail($nextPost->ID, array(300,150) );
}else{
$nextthumbnail =\'\';
}
next_post_link( \'<div class="nav-next">%link</div>\', $nextthumbnail . _x( \'%title <span class="meta-nav">→</span>\', \'Next post link\', nicosite\' ) );