use get_posts to get custom field data, but in one array

You can alter your foreach loop as following to get concert date and city pair in single multidimentional array as following.

$concert_query = array();
$i = 0;

foreach($c_query as $post) : setup_postdata($post); 

    $concert_query[$i]['concert_date'] = get_post_meta(get_the_ID(), 'concert_date', true);
    $concert_query[$i]['concert_city'] = get_post_meta(get_the_ID(), 'concert_city', true); 
    $i ++;
endforeach;

print_r($concert_query);

Leave a Comment