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
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.