So, I have a custom content type called "team" where I have an ACF field attached called "external" which is a checkbox. I am currently getting all the posts by passing the following arguments array to the get_post function.

 $args = array(
            'posts_per_page'   => -1,
            'offset'           => 0,
            'orderby' => 'menu_order', 
            'order' => 'ASC', 
            'post_type'        => 'team',
            'post_status'      => 'publish',


What I'd like to do is run this in two functions checking if the field is or is not checked, essentially filtering by who is and isn't internal. I'm not sure how to set the meta-query up for this.


So, the scattered documentation on this is really less than clear.

For checking for unchecked posts added the following meta_query:

    'meta_query' => array(array(
    'key' =>  'external',
    'value'  => '0',
    'compare' =>  '='

For filtering by checked it was just this:

     meta_query => array(array(
    'key' =>  'external',
    'value'  => '0',
    'compare' =>  '='
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.