对于多类别处理,您需要category__in
或atax_query
, 对于使用的多个自定义字段meta_query
. 中介绍了这两个方面的各种选项WP_Query
codex page.
$args = array(
\'posts_per_page\' => 10,
\'category__in\' => array( 163, 165 ),
\'meta_query\' => array(
array(
\'key\' => \'a_field\',
\'value\' => array( 1, 2 ),
\'compare\' => \'IN\'
),
array(
\'key\' => \'a_fieldd\',
\'value\' => 3,
\'compare\' => \'=\'
),
array(
\'key\' => \'a_fielddd\',
\'value\' => array( 1, 3, 5 ),
\'compare\' => \'IN\'
)
)
);
$results = new WP_Query( $args );
if( $results->have_posts() ){
while( $results->have_posts() ){
$results->the_post();
the_title();
}
}