Store metakey value as an array
I don’t think WP_Query returns the meta fields for you as well. So you need to loop over the posts and run get_post_meta() manually. Assuming one office has at max one _octopus_id, you could write it like this: // here we will store the ids $octopiIds = []; $query = new WP_Query([ ‘post_type’ => ‘office’, … Read more