How do I get all the posts where the value in wp_postmeta.meta_value is the selected city?
I now use the code below, but this doesn't work 100% because I use the LIKE method. So if I select "York" I get "York" and "New York".
The meta_value is sometimes translated with qtranslate-x and somethimes not. So
I have in the database:
meta_value = 'York'
meta_value = '[:en]New York[:es]Nueva York[:]'
The english value is always filled.
$metaFilter = array(
'city_clause' => array(
'key' => 'city',
'value' => '' . $selectedCity,
'compare' => 'LIKE'
),
);
$mypost = array(
'post_type' => 'post',
'paged' => get_query_var('paged'),
'posts_per_page' => 4,
'meta_query' => $metaFilter,
'orderby' => array(
'country_clause' => 'ASC',
'city_clause' => 'ASC',
),
);