Support

Account

Home Forums ACF PRO There can only be one field checked Reply To: There can only be one field checked

  • The best of the above solution is that if i have the same name field in other post types i can check them as featured and there can only be one – allways.

    And the query to put the featured post in the top off all posts:

    
    <?php
    $args = [
          'post_type' => ['post', 'evento'],
          'meta_key' => 'post_em_destaque',
          'orderby' => 'meta_value post_date',
          'post_status' => 'publish',
          'posts_per_page' => 6,
          'paged' => $paged
        ];
    $the_query = new WP_Query( $args );
    ?>
    
    

    And tho show and style the post as you wish inside the loop:

    
    <?php if ( $the_query->have_posts() ) : ?>
      <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
      
        <?php if ( get_field( 'post_em_destaque' ) ): ?>
          // The contetn of the featured post here
        <?php else: ?>
          // The rest of the posts
        <?php endif; ?>
      
      <?php endwhile; ?>
      <?php wp_reset_postdata(); ?>
    <?php endif; ?>
    

    Hope this can be useful for someone in time.