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(
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 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.