Home › Forums › General Issues › Advance wp_query with conditions… › Reply To: Advance wp_query with conditions…
banner_cats
is a multiselect field. This field will contain an array of category IDs and will be stored as a serialized array. You can’t do "IN"
or "="
here.
To match this you need to do something like this:
array(
'key' => 'banner_cats',
'value' => '"'.$cat_id.'"',
'compare' => 'LIKE',
)
Notice the double quotes include in the value. This is so that 1 will only match 1 and not 10, 20.
To do something resembling an “IN” you would need to loop through the list of categories and create a “LIKE” query for each of them.
The reason that you get nothing is that the meta queries on banner_cats
and banner_towns
are retuning nothing.
Hope that helps.
~JH
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.