get_the_excerpt 同じ記事が抜粋される
-
前後の記事の抜粋を表示したいのですが、同一記事の抜粋しか表示されません。
色々試したり、自分なりに調べてみましたが上手くいきません。最近wordpressを始めたばかりなので、分かりやすく教えていただけると助かります!
宜しくお願いします。<!–▼ページ送り▼–>
<?php
$prevpost = get_adjacent_post(true, ”, true); //前の記事
$nextpost = get_adjacent_post(true, ”, false); //次の記事
if( $prevpost or $nextpost ){ //前の記事、次の記事いずれか存在しているとき
?>
<div class=”cat_paging”>
<?php
if ( $prevpost ) { //前の記事が存在しているとき
echo ‘<dl class=”alignleft”><dt>前の記事(Previous)</dt><dd>ID) . ‘”><span class=”thumb”>’ . get_the_post_thumbnail($prevpost->ID, ‘thumbnail’) . ‘</span><span class=”title”>’ . get_the_title($prevpost->ID) . ‘</span><span class=”excerpt”>’ . get_the_excerpt($prevpost->ID) . ‘</span></dd></dl>’;
} else { //前の記事が存在しないとき
echo ‘<div class=”alignleft nopost”>TOPへ戻る</div>’;
}
if ( $nextpost ) { //次の記事が存在しているとき
echo ‘<dl class=”alignright”><dt>次の記事(Next)</dt><dd>ID) . ‘”><span class=”thumb”>’ . get_the_post_thumbnail($nextpost->ID, ‘thumbnail’) . ‘</span><span class=”title”>’ . get_the_title($nextpost->ID) . ‘</span><span class=”excerpt”>’ . get_the_excerpt($nextpost->ID) . ‘</span></dd></dl>’;
} else { //次の記事が存在しないとき
echo ‘<div class=”alignright nopost”>TOPへ戻る</div>’;
}
?>
</div>
<?php } ?>
<!–▲ページ送り▲–>
トピック「get_the_excerpt 同じ記事が抜粋される」には新たに返信することはできません。