我无法显示列表。我已经验证了帖子类型和分类法的slug。我所知道的这段代码之所以有效,是因为我曾将其用于其他帖子类型和分类法。如果您能了解这段代码在这里不起作用的原因,我将不胜感激。谢谢
<?php
$tag = \'commercial_for_lease\';
// Set up custom query with meta_query
$args = array (
\'post_type\' => \'wp-listings\', // your property post type slug
\'posts_per_page\' => 50,
\'orderby\' => \'rand\', // order by
\'order\' => \'ASC\', // Show earlier events first
\'tax_query\' => array(
array(
\'taxonomy\' => \'property-types\',
\'field\' => \'slug\',
\'terms\' => array($tag)
))
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) :
while ( $query->have_posts() ) : $query->the_post(); ?>
<div class="col-md-4" id="<?php echo get_the_id(); ?>">
<div class="row">
<a href="<?php the_permalink(); ?>">
<div class="item-container">
<div class="item-container-img">
<?php the_post_thumbnail(); ?>
</div>
<div class="item-container-text">
<h4><?php the_title(); ?><h4>
<h5><?php echo get_post_meta( get_the_ID(),\'listing-price\', true); ?></h5>
</div>
</div>
</a>
</div>
</div>
<?php endwhile; wp_reset_query(); ?>
<?php wp_reset_postdata();
endif;
?>