How to Increment ID value within ACF Repeater Field Loop

Try using a “counter” variable for the loop maybe? <?php if ( get_field(‘ingredients-list’) ) { echo ‘<ul class=”ingredientsList”>’; $count=0; while ( has_sub_field(‘ingredients-list’) ) { echo ‘<li class=”ingredient” itemprop=”ingredients”> <label for=”check-‘. $count .'”> <input type=”checkbox” class=”check” id=”check-‘. $count .'”> ‘; if ( get_sub_field(‘quantity’) ) echo ‘<span class=”quantity”>’ . get_sub_field(‘quantity’) . ‘</span> ‘; if ( get_sub_field(‘measurement’) ) … Read more

ACF if / else checkbox [closed]

Small fix for you 🙂 <?php if( in_array( “Yes”, get_field( ‘news__item–external’ ) ) ) { ?> <a href=”https://wordpress.stackexchange.com/questions/170396/<?php echo the_field(“news__item–external-url’); ?>” class=”more icon–chev”>View full article</a> <? } else { ?> <a href=”https://wordpress.stackexchange.com/questions/170396/home.php”>Home</a> <?php } ?> The code to fix was: <php } else { <a href=”https://wordpress.stackexchange.com/questions/170396/home.php”>Home</a> } ?> You was missing the end php tag … Read more

ACF Custom Field WP_Query, but need to get all posts, if field doesn’t exist

You can get both with an OR meta_query that also checks if the key does not exist: ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘event_date’, ‘compare’ => ‘NOT EXISTS’, ), array( ‘key’ => ‘event_date’, ‘value’ => date(“Ymd”, time()), ‘compare’ => ‘>’, ), ), ‘orderby’ => array( ‘meta_value_num’ => ‘DESC’, ‘date’ => ‘ASC’, ),

Replace post’s “the_content” with ACF value

Instead of updating the post’s content, you can filter it using the the_content filter. add_filter( ‘the_content’, ‘wpse241388_use_acf_field’ ); function wpse241388_use_acf_field( $content ) { return get_field( ‘article_text’ ); } Update To apply to only your article post type: add_filter( ‘the_content’, ‘wpse241388_use_acf_field’ ); function wpse241388_use_acf_field( $content ) { if ( is_singular( ‘article’ ) ) { $content = … Read more