Viewing 1 replies (of 1 total)
  • If you mean using the wp query loop to loop through all the locations and for each one print out the location_name and location_address then the following will work:

    <?php
    // Set up the query arguments to fetch all Events Manager locations
    $args = array(
    'post_type' => 'location',
    'posts_per_page' => -1, // Use -1 to retrieve all locations
    'post_status' => 'publish' // Only get published locations
    );

    $locations_query = new WP_Query( $args );

    // Check if any locations exist
    if ( $locations_query->have_posts() ) {
    echo '<ul class="em-locations-list">';

    // Start the loop
    while ( $locations_query->have_posts() ) {
    $locations_query->the_post();

    // The location name is the post title
    $location_name = get_the_title();

    // The address is stored in the '_location_address' meta field
    $location_address = get_post_meta( get_the_ID(), '_location_address', true );

    // Print the output
    echo '<li>';
    echo '<strong>' . esc_html( $location_name ) . '</strong><br>';
    echo esc_html( $location_address );
    echo '</li>';
    }

    echo '</ul>';

    // Restore original post data to prevent conflicts
    wp_reset_postdata();
    } else {
    echo 'No locations found.';
    }
    ?>

    Here are some other fields in the wp_postmeta table: _location_town, _location_state, _location_postcode, _location_country, _location_latitude, _location_longitude

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.