Currently trying to check and see if a venue coming from an API exists in EO based on its address/city/state. For testing purposes, I have removed the API calls and am just testing with hardcoded strings that are known to be in the database:
$venue_query = array(
array(
'key' => '_state',
'value' => 'NY'
)
);
$args = array(
'meta_query' => $venue_query,
);
$o .= var_export($args, true);
$eoVenues = eo_get_venues($args);
$o .= var_export($eoVenues, true);
return $o;
This code is run as part of a shortcode, and the output is:
array ( 'meta_query' => array ( 0 => array ( 'key' => '_state', 'value' => 'NY', ), ), )
array ( )
The first line of the output shows the query variables being passed into eo_get_venues(), and the second line shows that eo_get_venues() is returning an empty array. I have two venues that appear in the admin list which have states of NY, and two entries in the wp_eo_venuemeta table where key equals _city and value equals NY. When I remove the meta query, all venues are returned as expected.
WordPress version 6.5.2
Event Organiser version 3.12.5
PHP version 8.1
Let me know if there’s any other information I can provide that would be useful to help debug this
Beth Moeller
Digging into this a bit more, the Debug Bar plugin is showing the following query being executed:
SELECT DISTINCT t.term_id
FROM wp_terms AS t INNER JOIN wp_termmeta ON ( t.term_id = wp_termmeta.term_id ) INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id
WHERE tt.taxonomy IN ('event-venue') AND (
( wp_termmeta.meta_key = '_state' AND wp_termmeta.meta_value = 'NY' )
)
ORDER BY t.name ASC
This query was generated by WP_Term_Query->get_terms(), which through a few other functions was called by eo_get_venues(). It appears the issue is that the query is checking in wp_termmeta for the venue meta info, and not the wp_eo_venuemeta table.
Beth Moeller