Support

Account

Home Forums Add-ons Flexible Content Field Add one Flexible Content loop inside another

Solved

Add one Flexible Content loop inside another

  • I have two separate Flexible Content fields: Homepage and Inner Page. Using the Location options, each assigned to work with different page templates: homepage.php and inner-page.php and each work separately in their own loop.

    Is there a way to include a section added in the Inner Page Flexible Content into one of the sections of the Homepage Flexible Content.

    For example:

    if( have_rows( 'homepage' ) ):
       while ( have_rows( 'homepage'  ) ) : the_row();
    
          if( get_row_layout() == 'homepage_section' ) :
    
            // HTML
    
            if( have_rows( 'inner_page' ) ):
              while ( have_rows( 'inner_page'  ) ) : the_row();
    
               if( get_row_layout() == 'inner_page_section' ) :
    
                   // HTML
    
               endif;
    
              endwhile;
            endif;
    
          endif;
    
       endwhile;
    endif;
  • Yes, you just need to supply the post ID of the post where they are located when calling have_rows()

  • So simple. Thank you John!

  • Thanks for the report! Looking at your code, everything should work fine,

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.