• Resolved rolandksmith

    (@rolandksmith)


    In Pods Admin there is an option to delete all items from a pod, leaving an empty pod. Is there a function to do the same thing programmatically? At present I’m reading through a pod and deleting each item individually from a backup copy of a pod, then reading each entry in the production pod and adding to the backup pod. I’m thinking there just might be a better way…. Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    You can use the PodsAPI for this. It contains a method called reset_pod.

    $pod = $pods( 'pod_name' );
    $pod->api->reset_pod( $pod );
    

    Cheers, Jory

    Thread Starter rolandksmith

    (@rolandksmith)

    Thank you! Definitely a better way than I was going.

    Plugin Author Jory Hogeveen

    (@keraweb)

    You’re welcome! The best way to say thanks is to leave a 5 star review at https://wordpress.org/plugins/pods/ and (if you’re feeling especially generous) become a Friend of Pods at https://friends.pods.io/

    Cheers, Jory

    Thread Starter rolandksmith

    (@rolandksmith)

    Here’s what I eventually found that worked:

    $param = array('name'=>'$podToBeReset');
    $pods = pod($podToBeReset);
    if ($pod->api->reset_pod($param)) {
    echo "$podToBeReset has been reset";
    } else {
    echo "Resetting $podToBeReset failed";
    }
    
    • This reply was modified 2 years, 11 months ago by rolandksmith.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Delete All Entries from a Pod’ is closed to new replies.