我看过多篇帖子,但运气不好。我需要在现有目的中使用循环,但我永远也弄不清楚如何在自定义post类型中返回自定义分类法的术语。这是我的代码:
<?php $loop = new WP_Query(
\'post_type\' => \'dealmaker_pt\',
\'taxonomy\' => \'topics\',
\'field\' => \'slug\',
\'terms\' => \'dealoftheweek\',
\'posts_per_page\' => 50,
\'offset\' => 1 )
);
while ( $loop->have_posts() ) : $loop->the_post();
?>
stuffs here
<?php endwhile; wp_reset_query(); ?>
我的帖子类型是
dealmaker_pt
我的分类法是
topics
我试图显示
dealoftheweek
.
我该怎么做呢?
最合适的回答,由SO网友:Ravi Patel 整理而成
请对此使用有效格式Taxonomy Parameters
示例:
$args = array(
\'tax_query\' => array(
array(
\'taxonomy\' => \'topics\',
\'field\' => \'slug\',
\'terms\' => \'dealoftheweek\',
),
),
\'post_type\' => \'dealmaker_pt\',
\'posts_per_page\' => 50,
\'offset\' => 1
);
$query = new WP_Query( $args );