I created a select custom field. Each post has multiple cities in the field. I’m trying to run the following query below but it’s not working.
I set it up in the Choices box as cincinnati : Cincinnati
$args = array(
'numberposts' => -1,
'post_type' => 'post',
'meta_key' => 'city',
'meta_value' => 'cincinnati'
);
Any help would be greatly appreciated. I assume maybe it’s due to multiple values? If so what is the way around this?
I was able to solve this myself.
$location = $_GET["location"];
$args = array(
'numberposts' => -1,
'post_type' => 'post',
'meta_query' => array(
array(
'key' => 'city',
'value' => ''.$location.'',
'compare' => 'LIKE',
)
)
);
This reply has been marked as private.