WP_Queryつかって、category__in
category__not_in
を指定してはいかがでしょう。
【関数リファレンス/WP Query - WordPress Codex 日本語版】
https://wpdocs.osdn.jp/関数リファレンス/WP_Query#ふつうのループ(別の書き方)
php
1// the query
2$the_query = new WP_Query( $args ); ?>
3
4<?php if ( $the_query->have_posts() ) : ?>
5
6 <!-- pagination here -->
7
8 <!-- the loop -->
9 <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
10 <h2><?php the_title(); ?></h2>
11 <?php endwhile; ?>
12 <!-- end of the loop -->
13
14 <!-- pagination here -->
15
16 <?php wp_reset_postdata(); ?>
17
18<?php else : ?>
19 <p><?php esc_html_e( 'Sorry, no posts matched your criteria.' ); ?></p>
20<?php endif; ?>
【WP_Queryの使い方をPHPコードにまとめた便利なコード・スニペット】
http://notnil-creative.com/blog/archives/1288
PHP
1$args = array(
2 // ( 中略 )
3 'category__in' => array( 2, 6 ), //(array) - カテゴリーIDを指定する。
4 'category__not_in' => array( 2, 6 ), //(array) - カテゴリーIDを指定する。
5 // ( 中略 )
6);
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。