Home › Forums › General Issues › Display SUB field from a options page with relationship field on chosen pages › Reply To: Display SUB field from a options page with relationship field on chosen pages
You’d want something like:
if ( have_rows('people', 'option') ) while ( have_rows('people', 'option') ) {
the_row();
if ( in_array( get_the_ID(), array_merge( get_sub_field('relationship_field_for_posts'), get_sub_field('relationship_field_for_pages') ) ) {
the_sub_field('name');
echo '<br>';
the_sub_field('age');
}
}
This code would cycle through all items in the people repeater, then check to see if the current ID is in either the relationship field for posts, or the relationship field for pages. If found in one of those fields, it will print out the info.
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.