Home Forums Add-ons Flexible Content Field using a layout twice Reply To: using a layout twice

  • So playing around I was able to sort of trick it… I check to see if any layouts are left even if have rows is now false.

    $id = get_the_ID();
    $sections = get_field( 'sections'); //get the section names
    $sections_count = count($sections); //count them
    if( have_rows('sections', $id) ):
    //check if have row OR THERE ARE STILL LAYOUTS LEFT
        while( have_rows('sections', $id) || $sections_count ): the_row();
        $section = get_row_layout();
    //lower amount of layouts left
    //each layout has its own file. very clean output. It's how I do.
    		if( file_exists( locate_template( 'template-parts/blocks/' . $section . '.php') )) {
    			include( locate_template( 'template-parts/blocks/' . $section . '.php' ) );