Support

Account

Home Forums Add-ons Flexible Content Field Store single layout's content & load on another page Reply To: Store single layout's content & load on another page

  • My use of flex fields in likely rather different than others. I have a function similar to:

    
    functions do_layouts($post_id=false) {
       if (!$post_id) {
         // call function or figure out post id to use
       }
       if (have_rows('flex-field', $post_id) {
         while (have_rows('flex-field, $post_id) {
           the_row();
           $layout = get_row_layout();
           switch($layout) {
              // ...
              case 'global-panel':
                $gp = get_field('post-object', false, false); // ID only
                if ($gp) {
                  do_layouts($gp);
                }
                break;
              // ...
              default:
                get_template_part('template-parts/layouts/'.$gp);
                break;
           } // end switch
         } // end whild
       } // end if
    }