Home Forums ACF PRO Flexible content layouts not showing up in duplicated post


Flexible content layouts not showing up in duplicated post

  • Hello, I added the following code for duplicating custom post type posts to my functions.php:

    However, while the post_meta is correctly copied into the new post and static fields are being populated accordingly, the flexible content layouts won’t carry over and I’m presented with the Click the “Add Content” button below to start creating your layout message instead. The flexible content data is visible in the post_meta of the new post but the rows will neither show up on the Edit Post screen in the backend nor in the frontend. What am I doing wrong?

    Any help would be much appreciated. Thanks very much in advance.

  • I solved my problem by adding the following line in the variable declaration block of the duplicate post function.

    $flexible_content = get_field('YOUR_FLEXIBLE_CONTENT_FIELD', $post_id, false);

    And then the following lines in the if ($post) condition block.

    if ($flexible_content) {
        update_field('YOUR_FLEXIBLE_CONTENT_FIELD', $flexible_content, $new_post_id);
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.