Support

Account

Home Forums ACF PRO Query posts to create array with field values Reply To: Query posts to create array with field values

  • I should have added my current, non-working code. Please be gentle.

    $committees = array( 
        'numberposts' => -1,
        'post_type' => 'committee'
    ); 
    
    $query = new WP_Query($committees);
    $location_array = array();
    
    if( $query->have_posts() ): 
            while( $query->have_posts() ): $query->the_post();
    $location_array[get_field('committee_name')] = get_field('committee_location'); 
        endwhile;
        wp_reset_query();
    endif;