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;
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.