When you set up the meta_query value like:
'value' => "'" . $city . "'",
it gets translated to LIKE '%\'ondon\'%'
in the final SQL query, which matches things like L'ondon'
or L'ondon'er
but not London
.
But you actually want it to be like: LIKE '%ondon%'
– so you should do:
'value' => $city,
EDIT
Sorry, I haven’t noticed that this actually is Job Manager plugin related and the job_listing_region
is a taxonomy. In that case you should try to do something like:
// get taxonomy id's with names matching the query string $city
$foo_terms = get_terms( 'job_listing_region', array('name__like' => $city) );
$term_ids = [];
if ($foo_terms) {
foreach ($foo_terms as $foo_term) {
$term_ids[] = $foo_term->term_id;
}
}
// get jobs_listing entries matching retrieved id's
$args = array(
'post_type' => 'job_listing',
'post_status' => 'publish',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'job_listing_region',
'field' => 'term_id',
'terms' => $term_ids,
'operator' => 'IN'
)
)
);