• Resolved Xanthonius

    (@xanthonius)


    Hi all,

    I’m using this events manager for the first time and am trying to get the event location name from the post meta, I’ve been able to get everything else such as the event start date/end date, start time/end time, however the only thing the plugin returns in terms of a location is a single integer value. I assumed this was a post ID but that isn’t the case, is there a helper function or anything that the plugin uses to parse this value?

    I’ve tried something along the lines of these, both of which return nothing:
    get_post($post_meta['_location_id'][0]);

    get_posts(array(
    	'post_type' => 'location', 
    	'post__in' => array((int) $post_meta['_location_id'][0])
    ));

    Any ideas would be greatly appreciated 🙂

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Xanthonius

    (@xanthonius)

    I can probably write an SQL query to return this, the “_location_id” is returning 18, so you can see the connection in the DB here:
    Database tables

    Would prefer to use a utility function from the plugin if it’s available?

    Cheers

    Plugin Support angelo_nwl

    (@angelo_nwl)

    it’s not possible out the box at the moment. it may be possible with custom coding but unfortunately that’s not something we can help with but maybe you can try wp_query – https://wordpress.org/support/topic/em-with-wp_query-and-orderby-date/?replies=15

    Thread Starter Xanthonius

    (@xanthonius)

    No worries, I’ve done this which works if anybody else needs it:

    function get_event_location($location) {
      global $wpdb;
    
      if ($location) {
        $results = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "em_locations WHERE location_id = %d", $location));
        if ($results) {
          return $results;
        }
      }
    
      return false;
    }

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Getting location name from “_location_id” post meta’ is closed to new replies.