WordPressのテーマ、Underscores(_s)を使用している時に、個別の記事ページで"前記事","次記事"のリンクを削除する方法です。
日記のようなサイトの場合は、"前記事","次記事"があると順に読んでいくことができて便利ですが、Tipsを羅列したブログだと前後の記事に関連性が無いので、消してしまった方がすっきりするため、削除してみました。
個別記事で、"前記事","次記事"のリンクの削除方法
テーマの編集で、single.phpを開きます。single.phpは個別記事を描画する時のプログラムです。
下記の処理で、ページ記事本体と"前記事","次記事"のリンクを出力しています。
while ( have_posts() ) : the_post();
get_template_part( 'template-parts/content', get_post_format() );
the_post_navigation();
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
endwhile; // End of the loop.
WordPressでは、"前記事","次記事"のリンクを、the_post_navigation()関数で出力しているため、以下のような感じでコメントアウトすればよいです。
while ( have_posts() ) : the_post();
get_template_part( 'template-parts/content', get_post_format() );
// "前記事","次記事"のリンクを出さない
// the_post_navigation();
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
endwhile; // End of the loop.
こちらもおススメ