• T
  • T

Find All Posts Based on True/False Field in an Advanced Custom Fields Field

<!-- Find Highlighted Posts -->
 <?php 
 $posts = get_posts(array(
 'post_type' => 'post',
 'posts_per_page' => 3,
 'meta_query' => array(
 array(
 'key' => 'highlighted_post', // ACF Field
 'compare' => '==',
 'value' => '1'
 )
 )
 ));
 if( $posts ): ?> 
 <?php foreach( $posts as $post ): setup_postdata( $post ) ?>

<!-- Loop -->

<?php endforeach; ?>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
<?php wp_reset_query(); ?>
 
<?php wp_reset_postdata(); ?>