Skip Navigation

[Resolved] Recurring Issue with Post Duplication & Repeatable Group Content Using Toolset

This support ticket is created 2 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by Amir 2 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#2610267
Page Repeatable Group.png
Duplicated page.png
Issue duplicated Repeatable group.png

Dear Toolset Support Team,

I am writing to seek assistance with a recurring issue related to post duplication and repeatable group content on a WordPress website.

Software versions currently in use:

WordPress: 6.2.2
PHP version: 8.2.2
Theme: Custom - Twenty Twenty Three
Toolset Blocks: 1.6.7
Toolset Types: 3.4.19
Plugin: WP Duplicate Page (Ninja Team), although the issue persists across over 10 different plugins tried.
Custom Fields: "Reparaties_view"
Repeatable Group: "Tarieven_Reparatie"

The WP Duplicate Page plugin, while successful in cloning the main post, consistently fails to replicate the content within the "Tarieven_Reparatie" repeatable group. This results in a fragmented post duplication, creating substantial impact on the site's functionality and data consistency.

To provide a clearer understanding of the issue, I have attached three screenshots demonstrating the process and the resultant issue. These images capture the steps taken and the outcome observed when attempting to duplicate posts with repeatable group content.

This concern, as I've noticed, is not unique to my case. Past forum posts dating back to 2020 and 2022 highlight similar issues:

2022: https://toolset.com/forums/topic/i-want-help-for-duplicate-post-with-repeatable-fieldgroup/
2020: https://toolset.com/forums/topic/im-unable-to-duplicate-post-with-its-repeating-field-content-2/

Despite my numerous troubleshooting attempts, the issue remains unresolved, suggesting a deeper, more complex underlying problem.

Given your expertise, I am hopeful we can find a resolution for this persistent issue. Any guidance or steps towards a solution would be greatly appreciated.

Thank you in advance for your attention to this matter. I eagerly await your response.

Best Regards,
Amir

#2610385

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I understand the frustration of yours that it does not working,

Here is a simpler version. Its using "dp_duplicate_post" hook from the "Yoast Duplicate Post" plugin:
- hidden link

You should try to add the following code to "Custom Code" section offered by Toolset:
=> https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/#adding-custom-php-code-using-toolset

Example:

add_action( 'dp_duplicate_post', 'func_duplicate_child_posts', 50, 2 );
function func_duplicate_child_posts( $new_post_id, $post ) {

    /// replace with parent post slug
    $parent_post = 'student';    

      //// replace with repeating field group slug if required  
    $rfg_post = 'tarieven_reparatie';   

    if ( get_post_type( $new_post_id ) == $parent_post ) {
        $rfg_ids = toolset_get_related_posts($post->ID, $rfg_post,'parent',999,0,array(),'post_id','child');
            if(count($rfg_ids) > 0 ) {
                foreach($rfg_ids as $k=>$v):
                    // Copy post metadata
                    $data = get_post_custom($v);
                    $my_post = array(
                        'post_title'    => get_the_title($v),
                        'post_content'  => '',
                        'post_status'   => 'publish',
                        'post_author'   => $post->post_author,
                        'post_type'     => $rfg_post
                    );
                    // Insert the post into the database
                    $insert_post_id = wp_insert_post( $my_post );
                    // connecting RFG item to newly cloned $post_id
                    toolset_connect_posts($rfg_post, $new_post_id, $insert_post_id );
                    foreach ( $data as $key => $values) {
                        foreach ($values as $value) {
                            add_post_meta( $insert_post_id, $key, $value );
                    }
                }
                endforeach;
            }
    }
}
 

- Please change "student" with your original post type slug

Please let me know if it does not work as expected. If it does not work as expected, please send me admin access details with problem URL.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2610393

Hi Minesh,

Thanks for the quick reply and for the solution - the code is working just right.

I am, however, curious as to why this particular solution has not already been implemented into the plugin itself. Implementing this feature could enhance user experience and prevent similar issues from arising in the future. Do you think this will be added into the plugin anytime soon?

Thank you once again for your invaluable assistance. I look forward to your response.

Best regards,
Amir