Skip Navigation

[Resolved] delete all repeatable field group entries in php

This support ticket is created 3 years, 9 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
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9: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: Africa/Casablanca (GMT+01:00)

This topic contains 1 reply, has 2 voices.

Last updated by Jamal 3 years, 9 months ago.

Assisted by: Jamal.

Author
Posts
#2002537

I have a RFG called company-contacts, and a post-type called reps. I have many reps, and many company contacts listed in each rep. I have a need to delete all the reps and the company contacts to start fresh. Is there an easy way to accomplish this?

I planed on using this script to clear out the reps. I think it will work, but i want to clear the database of the company contacts as well. can this be done with the same script? if so, what slug should I use? if not, how else can I delete all of the RFG data?

$allposts= get_posts( array('post_type'=>'reps','numberposts'=>-1) );
foreach ($allposts as $eachpost) {
wp_delete_post( $eachpost->ID, true );
}

#2002811

Hello and thank you for contacting the Toolset support.

The following code will delete all post from the reps custom post type. Change the first line to use the RFG slug instead of the "reps" slug. Let's say the slug of the RFG is "company-contacts", use the following:

$allposts= get_posts( array('post_type'=>'company-contacts','numberposts'=>-1) );
foreach ($allposts as $eachpost) {
    wp_delete_post( $eachpost->ID, true );
}

Check this screenshot for the slug from my test site. My RFG slug is "cpt-books-comments" hidden link