Home › Forums › Front-end Issues › Get custom posts only by ACF custom category field › Reply To: Get custom posts only by ACF custom category field
I figured it out – simply put, I went waaaay off the tracks when I tried this initially but failed due to a conflict with custom functions in the theme, which I discovered in troubleshooting this issue. Had I known about the conflict I wouldn’t have been trying alternative methods and forgotten about the serialized array.
Since the value for the category name is a serialized array, a comparator was required. Here’s my array code, if it might help anyone:`$args = array(
‘post_type’ => ‘testimonial’,
‘posts_per_page’ => 20,
‘meta_query’ => array(
‘key’ => ‘tcat’, // from ACF custom field name
‘value’ => ‘”business”‘, // from ACF custom field checkbox options
‘compare’ => ‘LIKE’ // to match the string from the serialized ACF array
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've just released ACF 5.12.3 with a security fix to prevent arbitrary file uploads to forms with ACF fields.— Advanced Custom Fields (@wp_acf) July 14, 2022
Now that we've released this update, we recommend updating your sites as soon as possible.
© 2022 Advanced Custom Fields.