Support

Account

Home Forums Front-end Issues Need to filter post object by one taxonomy Reply To: Need to filter post object by one taxonomy

  • This is my current code:

    if( have_rows('cast') ):
       while ( have_rows('cast') ) :
          the_row();
    
             $cast_object = get_sub_field('actor_actress');
             if ( $cast_object) {
                $terms = get_object_terms($cast_object->ID, 'cast_crew_category', array('fields' => 'ids'));
                $thumbid = get_post_thumbnail_id($cast_object->ID);
                $thumb = wp_get_attachment_image_src( $thumbid, 'thumbnail' );
                $url = $thumb['0'];
                $role = get_sub_field('role');
    
                if (in_array('83', $terms)) {
                   echo $role; ?>
                   <a href="<?php echo get_permalink($cast_object->ID); ?>" rel="lightbox" data-lightbox-type="iframe"><img src="<?php echo $url; ?>" width="100%" height="auto"></a>
                   <a href="<?php echo get_permalink($cast_object->ID); ?>" rel="lightbox" data-lightbox-type="iframe"><?php echo $cast_object->post_title; ?></a>
                <?php }
             }
       endwhile;
    endif;