Support

Account

Forum Replies Created

  • Turned out it was a plugin causing it to break! Called ‘Advanced Floating Content’ in case anybody else runs into this issue!

  • It worked! I had no idea this function existed… do you mean a script in ACF or in WP?

  • No that’s fine, thanks for replying, i appreciate it 🙂

    I think the process of this working, will be very useful for me moving forward, as i want to auto populate some fields etc, so gonna see just how it works for ‘options page’ fields.

  • For others i worked out the solution.

    So essentially you use the update_field, then update_post.

    Example:

    
    // Flexible element
    $fc_key = "field_key_for_flexible_content";
    
    // build the rows to insert
    
    $fc_rows = array(
      array(
                'field_key_for_field_inside_flexible_layout' => '',
                'acf_fc_layout' => 'name_of_layout_inside_flexible_item'
            ),
      array(
                'field_key_for_field_inside_flexible_layout' => '',
                'acf_fc_layout' => 'name_of_layout_inside_flexible_item'
            ),
    );
    
    // run the update
    update_field( $fc_key, $fc_rows, $post_id );
    
    // update
    wp_update_post( array (
      'ID' => $post_id,
    ));
    
  • I’ve created a plugin which does a ‘fresh sync’ from an API, which destroys the old posts, and re-creates them. I then want to make a generic structure to be placed back in by default.

  • Hi there. Hoping someone can help!

    I have a issue with flexible content fields.

    So i’ve created one, with a bunch of options.

    I’ve gone into the database, copied out the fields it generates (including the _ key fields and the flexible content one itself (has: a:1:{i:0;s:36:”content_panel_accommodation_features”;}) inside.

    Now when I to the insert into the post_meta table it works (other then for some reason add_post_meta adding s:xx( to the start of the json string for that field). But got around that with WPDB.

    However, when you view the editor page, it shows up all the fields, however on the template it doesn’t appear to have saved it correctly (as it’s showing up all the fields as arrays in a var dump).

    This get’s corrected when i click ‘update’ on the post… but need it to work without needing to do that.. any ideas?

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