Support

Account

Home Forums ACF PRO Check for a value in a custom query Reply To: Check for a value in a custom query

  • 
    if ( $all_query->have_posts() ) {
      // add a variable that will treack tha last section shown
      $last_value = '';
      ?>
      <h2 id="opmeer" class="">Iedereen</h2>
      <div class="<?php echo $column_class; ?>">
        <?php
        // Start the loop.
        while ( $all_query->have_posts() ) {
          $all_query->the_post();
          
          // check the value of this against last shown
          if (get_field('your_field_name') != $last_value) {
            // ourput heading for next section
            // your code here
            
            // set last value to this value
            $last_value = get_field('your_field_name');
          }
          
          
          get_template_part( 'loop-templates/content-collegas', get_post_format() );
        }
    } else {
      get_template_part( 'loop-templates/content', 'none' );
    }