$args = array(
\'post_type\' => \'shows\',
\'operator\' => \'AND\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'location\',
\'field\' => \'slug\',
\'term\' => \'california\',
),
array(
\'taxonomy\' => \'genre\',
\'field\' => \'slug\',
\'term\' => \'comedy\',
)
)
);
$my_query = new WP_Query();
$my_query->query($args);
while ( $my_query->have_posts() ) : $my_query->the_post();
echo \'<li>\';
the_title();
echo \'</li>\';
endwhile;
wp_reset_postdata();
我的分类法:
register_taxonomy(\'location\',array (
0 => \'shows\',
),array( \'hierarchical\' => true, \'label\' => \'location\',\'show_ui\' => true,\'query_var\' => true,\'rewrite\' => array(\'slug\' => \'location\'),\'singular_label\' => \'location\') );
register_taxonomy(\'genre\',array (
0 => \'shows\',
),array( \'hierarchical\' => true, \'label\' => \'genre\',\'show_ui\' => true,\'query_var\' => true,\'rewrite\' => array(\'slug\' => \'genre\'),\'singular_label\' => \'genre\') );
我的目标是显示带有“前加州”和“喜剧”两个词的帖子,我试图建立这种关系,但遗憾的是没有显示结果