ACF Flexible Content with Latest Posts with ACF field to select numbers of Posts

<?php while(has_sub_field("section_selector")): ?> <?php if(get_row_layout() == "select_elementor_section"):?> <?php $sectionId = get_sub_field('choose_section'); echo do_shortcode('[elementor-template id="'.$sectionId.'"]'); ?> <?php elseif(get_row_layout() == "latest_posts"):?> <div> <?php $postNumber = get_sub_field('select_number_of_posts'); $args = array('posts_per_page' => $postNumber, 'orderby'=>"title", 'order'=>"asc"); $postType = new WP_Query( $args ); if( $postType->have_posts() ) { while( $postType->have_posts() ) { $postType->the_post(); ?> <div style="color:#fff;"><?php the_title();?></div> <div style="color:#fff;"><?php the_excerpt();?></div> <?php } } wp_reset_query(); ?> </div> <?php endif; ?> <?php endwhile; ?>

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.