如果post对象post具有特定的自定义分类术语,我将尝试有条件地显示div。自定义分类法称为“room\\u空缺”,术语称为“booked”
我正在使用以下代码,但它不起作用:
<?php $post_objects = get_field(\'bedrooms_object\');
if( $post_objects ): ?>
<h2>Bedrooms</h2>
<ul class="bedrooms">
<?php foreach( $post_objects as $post_object): ?>
<li class="bedroom">
<div class="inner row">
<div class="col-md-5 image">
<?php if ( is_tax( \'room_vacancy\', \'booked\') ) { ?>
<div class="label">Booked</div>
<?php } else { ?>
<?php } ?>
<img class="lazy" src="<?php echo get_the_post_thumbnail_url($post_object->ID, \'large\'); ?>"/>
<div class="details">
<div class="price">Price <span><?php the_field(\'room_price\', $post_object->ID); ?><span></div>
<div class="size">Size: <span><?php the_field(\'room_size\', $post_object->ID); ?></span></div>
</div>
</div>
<div class="col-md-7 content">
<h2><?php echo get_the_title($post_object->ID); ?></h2>
<?php the_field(\'listing_content\', $post_object->ID); ?>
<a class="btn" href="<?php the_field(\'button_url\', $post_object->ID); ?>">Apply Now</a>
</div>
</div>
</li>
<?php endforeach; ?>
</ul>
<?php endif;?>
有什么建议吗?