WordPressでは、サイトの最初のindex一覧では、投稿の新しい日付順に並んでいるのでR。
このindex一覧を、特定のカテゴリーだけにしたいのでR。
テーマによっては、index一覧を特定カテゴリーできる場合もR。その場合は、たいがい「外観」→「カスタマイズ」でその項目があるのでR。
しかし、
一般的なテーマはそれがないのでR。そのために、サイトの最初のindex一覧を特定のカテゴリーに固定するには、ソースをいじる必要があるのでR。
まずは、「外観」→「テーマ編集」でindex.phpを覗くのでR。
例えば、このTwenty Sixteenでは、
<?php // Start the loop. while ( have_posts() ) : the_post(); /* * Include the Post-Format-specific template for the content. * If you want to override this in a child theme, then include a file * called content-___.php (where ___ is the Post Format name) and that will be used instead. */ get_template_part( 'template-parts/content', get_post_format() ); // End the loop. endwhile;
があるのでR。このwhile ( have_posts() ) : the_post();のループが始まる前の
<?php
の前に、
<?php query_posts("cat=1");>
を挿入するのでR。ここではカテゴリー”1″の一覧がindex一覧となるのでR。ちなみに、カテゴリーのIDの番号は、
「投稿」→「カテゴリー」を覗いて、カテゴリーの名前の上にマウスカーソルを置くと、左下に
と出るので、そこに書いてある番号がカテゴリーのIDとなるのでR。この図の場合は”3″なのでR。
詳しくは、ここを参考にするのでR。




この記事をシェアできます。
その他の記事
-
WordPressのContact Form 7で確認チェックを付けるのでR
-
WordPressでフッターにウィジェットを配置するのでR
-
WordPressで関連記事の表示をプラグインでするのでR ver.2
-
WordPressで言語選択の機能を追加するのでR
-
WordPressで自動でアイキャッチ画像を挿入するのでR
-
WordPressでif文によるログインとログアウトでの条件分岐を記述するのでR。
-
WordPressで新しいエディターのGutenbergを無効にするのでR
-
WordPressで関連記事の表示をプラグインでするのでR
Warning: Undefined variable $counter in /home/daslabo/daslabo.com/public_html/naruhesogoma.daslabo.com/wp-content/themes/twentysixteen/template-parts/content-single.php on line 117