Support

Account

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