Support

Account

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
    )
    )
    );
    `