Home Forums ACF PRO If ACF Post Object post has custom taxonomy term…


If ACF Post Object post has custom taxonomy term…

  • I’m trying to conditionally display a div if a post object post has a specific custom taxonomy term. The custom taxonomy is called ‘room_vacancy’ and the term is called ‘booked’

    I’m using the following code but it doesn’t work:

    			$post_objects = get_field('bedrooms_object');
    			if( $post_objects ): ?>
    			    <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 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>
    			    <?php endforeach; ?>
    			<?php endif;?>

    Can you please advise where I’m going wrong?

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.