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' );
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.