I have an array of city names
$cities = array('Ludhiana','Doraha','Jagraon','Moga','Phillaur','Ahmedgarh');
In my wordpress implementation, I have a custom-field named ‘cty_name’
Now, I want to query those posts which contains any array value in the ‘cty_name’ custom field. I know this could be done using meta_query in Wp_Query function, but could not figure this out.
Please lead me to a fast and efficient way to get these posts, actually I would be having approximately 100 values in the array, and that would be inefficient to compare each value with the posts.
Thank You,
EDIT :
I solved the Problem, it was an easy one though… Thanx all for your kind support
$cities = array('Ludhiana','Doraha','Jagraon','Moga','Phillaur','Ahmedgarh');
$args = array(
'post_type' => 'city_posts',
'meta_query' => array(
array(
'key' => 'cty_name',
'value' => $cities,
'compare' => 'IN'
)
)
);
I solved the Problem, it was an easy one though… Thanx all for your kind support
Try this for size with
wp_query
, im going to infer that your key iscty_name
:Try to use this one