我试图显示所有使用自定义分类法的帖子。我认为问题在于,我的代码没有生成术语数组。
$clients_terms = get_terms(\'clients\');
$clients_query = new WP_Query( array(
\'post_type\' => \'work\',
\'posts_per_page\' => 4,
\'tax_query\' => array(
array(
\'taxonomy\' => \'clients\',
\'field\' => \'slug\',
\'terms\' => array($clients_terms->slug)
)
)
) );
if ( $clients_query->have_posts() ): ?>
<ul class="work_list">
<?php while ( $clients_query->have_posts() ) : $clients_querys->the_post(); ?>
<li><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a> </li>
<?php endwhile; wp_reset_postdata(); ?>
</ul>
我可以为单个术语生成帖子,但不能为所有使用分类法的帖子生成帖子。