Support

Account

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 ?