WP_Query を使用します。このような:
$ThisQuery = new WP_Query( array( 'category_name' => 'MyCategory',
'meta_key' => 'MyCustomFieldValue',
'posts_per_page' => 10 ) ); // Number of posts
if ( $ThisQuery->have_posts() ) : while ( $ThisQuery->have_posts() ) : $ThisQuery->the_post();
...
endwhile;
endif;
wp_reset_postdata();
配列を変更して、取得する投稿を識別する要素を含めます
もう一つの例:
<?php
$Args = array( //Category
'cat' => 5, // Category id.
'category_name' => 'MyCategory', // Category Name.
//Taxonomy
'tax_query' => array( 'relation' => 'AND', // Could be OR
array( 'taxonomy' => 'MyTaxonomy1',
'field' => 'MySlug1',
'terms' => array( 'MyTerm11',
'MyTerm12' ), ),
array( 'taxonomy' => 'MyTaxonomy2',
'field' => 'MySlug2',
'terms' => array( 'MyTerm21',
'MyTerm22',
'MyTerm23' ), ) ), );
$ThisQuery = new WP_Query( $Args );
if ( $ThisQuery->have_posts() ) : while ( $ThisQuery->have_posts() ) : $ThisQuery->the_post();
// Do Stuff
endwhile;
endif;
?>