Home › Forums › General Issues › merge contents of 2 subfields to one result › Reply To: merge contents of 2 subfields to one result
This may be close, but i may not be understanding it. My main cpt is the event, so I thought that I would be querying that post. so say i wanted to see all the speakers (both normal and frontpage) from the most recent event…
I was thinking something like this:
$query = new WP_Query(
array(
'post_type' => 'events',
'posts_per_page' => '1',
'order' => 'DESC',
)
);
$count = $query->post_count;
$i = 1;
while ( $query->have_posts() ) : $query->the_post();
$speakers = array_merge(
get_field('relationship_1', false, false),
get_field('relationship_2', false, false));
if($speakers):
echo '<ul>';
foreach( $speakers as $speaker ):
echo '<li>'.get_the_title($speaker -> ID).'</li>';
$i++;
endforeach;
echo '</ul>';
endif;
endwhile;
wp_reset_postdata();
?>
does that make sense?
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.