Support

Account

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

  • Display only selected items:

    <?php
    $args = array(
    	'post_type' => 'post',
    	'posts_per_page' => -1,
    	'post_status' => 'publish',
    	'order' => 'DSC',
    	'meta_query' => array(
    		'relation' => 'AND',
    		array(
    			'key'     => 'exclude_post',
    			'value'   => '1',
    			'compare' => '=',
    		),
    		array(
    			'key'     => 'exclude_post',
    			'compare' => 'EXISTS',
    		)
    	)
    );
    $query = new WP_Query( $args );
    
    if ( $query->have_posts() ) :
    	while ( $query->have_posts() ) :
    		$query->the_post();
    
    		echo '<br/>';
    		the_title();
    
    	endwhile; 
    	wp_reset_postdata();
    endif; ?>

    Hide selected items:

    <?php
    $args = array(
    	'post_type' => 'post',
    	'posts_per_page' => -1,
    	'post_status' => 'publish',
    	'order' => 'DSC',
    	'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();
    
    		echo '<br/>';
    		the_title();
    
    	endwhile; 
    	wp_reset_postdata();
    endif; ?>