Home › Forums › Add-ons › Repeater Field › Repeater Relationship Post Fields from Array › Reply To: Repeater Relationship Post Fields from Array
Hi @rktlwm
Thanks for the follow up and the attachments. I can now see how you need to work with the data.
What you need to do is loop over the repeater field and look at the selected case. Load the case’s type (internal / external) and then append this data to an array.
After the repeater field loop is complete, you should have an array containing all the external and all the internal cases. You can then loop through these and output the 2 lists like so:
<?php
$internal = array();
$external = array();
if ( get_field('test_cases') ): ?>
<?php while(has_sub_field('test_cases')):
// get case
$case = get_sub_field('case_relationship');
$case = array_pop($case);
// get case data
$data = array(
'type' => get_field('type', $case),
'description' => get_sub_field('case_custom_desc'),
'title' => get_the_title($case),
'link' => get_permalink($case)
);
$type = get_field('type', $case);
$description = get_sub_field('case_custom_desc');
$title = get_the_title($case);
$link = get_permalink($case);
if( $type == 'internal' )
{
$internal[] = $data;
}
else
{
$external[] = $data;
}
?>
<?php endwhile; ?>
<?php endif; ?>
Please note the above code is untested. So with this code, you will have all the case data in 2 arrays (internal and external) which you can loop over and output into the 2 columns for each post.
Good luck
Thanks
E
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.