Home Forums General Issues check box query Reply To: check box query

  • Hi @saberap

    I’m afraid I don’t understand your goal. Could you please let me know the result you want?

    Also, it seems there are some syntax errors in your code. First, you forgot to add the PHP closing and opening tag before and after the div element. Second, kindly avoid using $posts variable as it’s sometimes used by WordPress. Third, you need to loop through the returned posts list to show the checkbox value for each post. And lastly, you need to pass the post ID because the code is executed outside of The Loop.

    So, it should be like this:

    // use another variable than "$posts"
    $the_posts = get_posts(array(
        'meta_query' => array(
                'key' => 'facilities', // name of custom field
                'value' => '"red"', // matches exactly "red"
                'compare' => 'LIKE'
    // don't forget the PHP closing tag
    <div class="facilities">
    // and also the PHP opening tag
    if( $the_posts ) {
        // loop through the posts
        for( $the_posts as $the_post ){
            // show the value
            the_field('facilities', $the_post->ID );

    I hope this makes sense 🙂