lundi 1 janvier 2018

Advanced Custom Field checkbox query not working

I am using an Advanced Custom Field to allocate a custom field to posts. This field is then used by a filtering system to filter posts using a custom query (via the pre_get_posts action). The other query arguments are working fine, except for the one which relies on ACF’s field.

The current query arguments of the field’s meta_query have been constructed according to the ACF documentation for the field (hence the quotation marks surrounding the value).

Can anyone advise me as to where this is going wrong? The query doesn’t seem to return any posts based on the values I am passing to the query.

Query arguments:

$courses = get_query_var('courses');
if ($courses) {
    $query->set('meta_query', array(
            array(
                'key' => 'course_check',
                'value' => '"'.$courses.'"', //i.e mdia-403
                'compare' => 'LIKE'
            ),
        )
    );
}




Aucun commentaire:

Enregistrer un commentaire