Support

Account

Home Forums Add-ons Flexible Content Field Can only output 6 layouts from my Flexible Content field Reply To: Can only output 6 layouts from my Flexible Content field

  • Found the issue. I was trying to call WP posts in a <?php elseif( get_row_layout() == 'featured_news' ): ?>

    
    <?php
    $tags = get_sub_field('tags');
    $args = array(
    'post_type' => 'post',
    'post_status' => 'publish',
    'tag' => $tags,
    'posts_per_page' => 5,
    );
    $arr_posts = new WP_Query( $args );
    if ( $arr_posts->have_posts() ) :
    while ( $arr_posts->have_posts() ) :
    $arr_posts->the_post();
    ?>	
    ...output
    <?php
    endwhile; 
    endif;
    ?>
    

    but needed to have wp_reset_postdata(); at the bottom like:

    
    <?php
    $tags = get_sub_field('tags');
    $args = array(
    'post_type' => 'post',
    'post_status' => 'publish',
    'tag' => $tags,
    'posts_per_page' => 5,
    );
    $arr_posts = new WP_Query( $args );
    if ( $arr_posts->have_posts() ) :
    while ( $arr_posts->have_posts() ) :
    $arr_posts->the_post();
    ?>	
    ...output
    <?php
    endwhile;
    wp_reset_postdata(); <=NEEDED THIS
    endif;
    ?>

    May help someone else