我有这个循环,效果很好,但cpt Studio是分层的,我只想在循环中显示第一级帖子。。我找不到解决方案。。。
<?php
$post_type = \'studio\';
// Get all the taxonomies for this post type
$taxonomies = get_object_taxonomies( array( \'post_type\' => $post_type ) );
foreach( $taxonomies as $taxonomy ) :
// Gets every "category" (term) in this taxonomy to get the respective posts
$terms = get_terms( $taxonomy );
foreach( $terms as $term ) : ?>
<div class="col-lg-3 col-xs-12 box">
<div class="inner-content">
<?php $args = array(
\'post_type\' => $post_type,
\'posts_per_page\' => -1,
\'tax_query\' => array(
array(
\'taxonomy\' => $taxonomy,
\'field\' => \'slug\',
\'terms\' => $term->slug,
)
)
);
$posts = new WP_Query($args);
if( $posts->have_posts() ): while( $posts->have_posts() ) : $posts->the_post(); ?>
<a href="<?php echo get_permalink(); ?>" title="Read more about <?php echo get_the_title(); ?>">
<?php echo get_the_title(); ?>
</a>
<?php endwhile; endif; ?>
</div>
</div>
<?php endforeach;
endforeach; ?>