我希望有人能帮助我:
我有一个Custom Post Type (电影)及其custom taxonomy (生产者),此分类法有其own terms, 例如“WarnerBros”。
我怎样才能得到我任期内的所有职位(WarnerBros)?
我有这个,但还没用。
$args = array(
\'post_type\' => \'movie\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'producer\',
\'field\' => \'slug\',
\'terms\' => \'WarnerBros\',
),
),
);
$query = new WP_Query( $args );
在使用解决问题的代码后,我将与具有相同问题的人共享我的代码:
$type = \'Movie\'; // Custom Post Type Name
$tag = \'WarnerBros\'; // Your Term
$args = array(
\'post_type\' => $type,
\'paged\' => $paged,
\'posts_per_page\' => -1,
\'orderby\' => \'menu_order\',
\'order\' => \'ASC\',
\'tax_query\'=>array(
array(
\'taxonomy\'=>\'Producer\', //Taxonomy Name
\'field\'=>\'slug\',
\'terms\'=>array($tag)
))
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
if(is_object_in_term($post->ID,\'Taxonomy_Name\',\'Your_Term\')) // Producer and WarnerBros {
echo \'<div id="YourID">\'; echo the_title(); echo \'</div>\';
} endwhile;