Support

Account

Home Forums General Issues merge contents of 2 subfields to one result Reply To: merge contents of 2 subfields to one result

  • Hi all, and John,

    I am looking to do something I think is this, but not totally sure: I need one field the user chooses one value from, that is a combination of posts of category “dogs”, and also of specific categories themselves, “dogs”, “cats”.

    It seems that the Post Object and Taxonomy are the right choices, now I just need to merge them into one select. This field will be on the options page.

    I am trying the code John shared before:

    $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

    But, trying I’m unsure how to go from
    $speakers = new WP_Query($args);

    to the new field of merged fields – I get syntax error with the snippet in my functions.php. Do i need to instead assign the merged array $args into a new ACF select field? I probably create that field, and assign the array to it?

    The data will be used on many different posts, and archive pages, that’s why it’s in my ACF Options page.

    Thanks.