Support

Account

Home Forums ACF PRO True/False – No Value for False Reply To: True/False – No Value for False

  • Hey,

    This not work for the NULL case.
    You can use var_dump(get_field( 'exclude_post' )); to test.

    <?php
    $args = array(
    	'post_type' => 'post',
    	'posts_per_page' => -1,
    	'meta_query' => array(
    		'relation' => 'OR',
    		array(
    			'key'     => 'exclude_post',
    			'value'   => '0',
    			'compare' => '='
    		),
    		array(
    			'key'     => 'exclude_post',
    			'compare' => 'NOT EXISTS'
    		)
    	)
    );
    $query = new WP_Query( $args );
    
    if ( $query->have_posts() ) :
    	while ( $query->have_posts() ) :
    		$query->the_post();
    
    		the_title();
    
    	endwhile; 
    	wp_reset_postdata();
    endif; ?>