Home › Forums › Add-ons › Flexible Content Field › Display flexible content on category archive page › Reply To: Display flexible content on category archive page
I have a similar issue, though with multiple Flexible Content loops on the Category page.
My goal is to just get the first ‘paragraph’ content type for each post (these are custom post types with specific content defined for them, via ACF.
So, if I use:
<p class="lead">
<?php if (have_rows('flexible_content_types')): ?>
<?php while (have_rows('flexible_content_types')): the_row(); ?>
<?php if (get_row_layout() == 'paragraph_content'): ?>
<?php echo truncate( get_sub_field('content' ), 120); ?>
<?php break; ?>
<?php endif; ?>
<?php endwhile; ?>
<?php else: ?>
NO CONTENT
<?php endif; ?>
</p>
It works, for the FIRST ONE.. then I run another loop:
<?php
$featured = get_posts( array(
'post_type' => 'post',
'numberposts' => 2,
'tag' => 'featured',
'cat' => 3,
'ignore_sticky_posts' => 1,
'offset' => 0
));
if ( $featured ): ?>
<?php foreach( $featured as $post ): setup_postdata( $post ); ?>
... etc.. and run flex content loop here...
and use the same flexible content loop from above.. doesn’t work on the second, third, etc. loops.
Any ideas? What am I doing wrong here?
IF I use the recommended code from above:
$object = get_queried_object();
$post_id = $object->taxonomy.’_’.$object->term_id;
Then one of the flexible content loops works, the others do not…
any suggestions ?
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.