how to get the qtranslate-x meta_value in wp_postmeta using WP_Query?

admin2025-06-03  9

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',
        ),
);
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748902251a314673.html

最新回复(0)