Support

Account

Forum Replies Created

  • 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; 
  • That does indeed work beautifully for populating the committee dropdown. Any thoughts on using that selection to set the default values for the meeting fields?

  • I suppose I could side-step this by coding conditional logic on the template (display meeting_location for this meeting if it exists, else display default_location for this committee), but I think it would be a better user experience for the person creating the meeting to see the default location, and overwrite it if necessary.

  • Thanks, James. Although this method centers the map, it doesn’t pre-populate the address field or set a marker. And without setting a marker, get_field returns nothing, defeating the purpose of the default value.

    And if the default were ever to change, a future person would have to know to edit our functions.php file, including lat and lng values.

    The alternative, using the text field, requires first geocoding the text and then integrating those values into Google’s js embed code. I’d hoped to avoid that sort of mucking around.

Viewing 4 posts - 1 through 4 (of 4 total)