Title: Database table fields access through wp Query
Last modified: September 18, 2026

---

# Database table fields access through wp Query

 *  [Andy Dickinson](https://wordpress.org/support/users/dickina/)
 * (@dickina)
 * [22 hours, 38 minutes ago](https://wordpress.org/support/topic/database-table-fields-access-through-wp-query/)
 * Hi,
 * Is there a way that I can access the location database fields such as location_name,
   location_address through a wp query loop?

Viewing 1 replies (of 1 total)

 *  [joneiseman](https://wordpress.org/support/users/joneiseman/)
 * (@joneiseman)
 * [22 hours, 10 minutes ago](https://wordpress.org/support/topic/database-table-fields-access-through-wp-query/#post-19023741)
 * 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:
 *     ```wp-block-code
       <?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 existif ( $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](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fdatabase-table-fields-access-through-wp-query%2F%3Foutput_format%3Dmd&locale=en_US)
to reply to this topic.

 * ![](https://ps.w.org/events-manager/assets/icon-256x256.png?rev=3550347)
 * [Events Manager - Calendar, Bookings, Tickets, Appointments and more!](https://wordpress.org/plugins/events-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/events-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/events-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/events-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/events-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/events-manager/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [joneiseman](https://wordpress.org/support/users/joneiseman/)
 * Last activity: [22 hours, 10 minutes ago](https://wordpress.org/support/topic/database-table-fields-access-through-wp-query/#post-19023741)
 * Status: not resolved