Support

Account

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.