How to filter get_post with ACF by a checkbox field?

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.

Topic advanced-custom-fields get-posts Wordpress

Category Web


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' =>  '='
    ))

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.