Support

Account

Home Forums Add-ons Flexible Content Field Page Builder w/Flexible Content. Create row

Solved

Page Builder w/Flexible Content. Create row

  • I needed to export all existing Posts from one site to the new site. The old posts had all content in the_content() so the import sent data there in new posts. I need to move the content out of the default WYSIWYG and more it into a content block inside my ‘One Column’ block builder. I can do this no problem when the One Column has been triggered and saved with some holder text, but I am doing that manually. How can I trigger that One Column to trigger and save so I can then run an update.

    while ( have_rows('page_builder') ) : the_row();
    if( get_row_layout() == 'one_column' ): // Single Column
    /// This works only when one_column has already been created. I am starting from scratch.
    update_field('field_60745782d2943', get_the_content());
    endif;
    endwhile;

    What needs to happen to create a row layout section? I see add_action(), add_row(), update_sub_field()…. I have now wrapped myself in knots!

  • When the field “page_builder: does not exist you need to create it.

    
    $value = array(
      // nested array for each row you want to create
      array(
        // field key => value pairs for row
        'acf_fc_layout' => 'one_column',
        'field_60745782d2943' => get_the_content();
      )
    )
    update_field('field_key_of_flex_field', $value, $post_id)
    
  • Thank you! It was the acf_fc_layout call I was missing!

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

You must be logged in to reply to this topic.