Support

Account

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

Solved

Add one Flexible Content loop inside another

    • Vasili

    • November 19, 2020 at 10:17 pm

    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()

    • Vasili

    • November 20, 2020 at 9:42 am

    So simple. Thank you John!

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

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.