Home › Forums › General Issues › merge contents of 2 subfields to one result › Reply To: merge contents of 2 subfields to one result
Not sure if this is the best solution or not, but it’s what I’d do. In that one place where you want them to appear together get each of the fields without formatting, this is done by specifying the 3rd argument for get_field() to tell acf not to format the value the second argument is the optional post id, which you can set to false for the current post. Merge the 2 arrays and then do a post__in query to get hem all sorted the way you want.
$all = array_merge(
get_field('relationship_1', false, false),
get_field('relationship_2', false, false));
$args = array(
'post_type' => 'speakers',
'posts_per_page' => -1,
'post__in' => $all,
'orderby' => 'title'
)
$speakers = new WP_Query($args);
// post loop
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.