WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using the Advanced Custom Field (ACF) plugin in a Custom Post Type (CPT).

I have field group in ACF that contains a Image field and true/false field called 'home_offer'.

I'm using this ACF in a Custom Post Type called Offers.

I want to loop through the CPT Offers and check if the true/false field 'home_offer' is checked.

How do I check if the true/false field is selected.

Ive started with this WP_Query.

    <div id="offers">
                $offers_args = array(
                    'post_type' => 'Offers',
                    'post_per_page' => 1,
                    'meta_query' => array(
                                'key'       => 'home_offer',
                                'value'     => 'on',
                                'compare' => '=', 
                                'type'      => 'CHAR'

                $offers_loop = new WP_Query($offers_args);


                $image = get_field('image');        


            <div id="offerLeft">

                <img src="<?php echo $image ?>" alt="" />






share|improve this question
up vote 3 down vote accepted

First of all, 'post_per_page' => 1 in your code is wrong, right name of the argument is posts_per_page (note the plural in postS_per_page)

then if you want query for a 'true/false' field in ACF you have to use

'meta_query' => array(
    'key' => 'home_offer',
    'value' => '1',
    'compare' => '=='

See ACF docs

share|improve this answer

The following code works for WordPress >= 3.5 (source). I couldn't get it to work the ACF way. No need to use 'meta_query' this way. Just replace 'meta_query' with the following two lines to offer_args and and it should work.

'meta_key'     =>   'home_offer',
'meta_compare' =>   'EXISTS', // or 'NOT EXISTS' if no offer.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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