I'm looking for a safe and fast way to delete all of one custom post type's posts. Using get_posts()
and wp_delete_post()
for each returned post does not work; it's not fast enough due to the sheer amount of database queries involved (timeout error).
Preferably, I'm looking for a single database query to run that deletes all posts that are of a custom post type. Any thoughts?
wpdb
class then. Preferred method and "the WP way" for working directly with the DB. Let us know if you need help with that query. I can post a full answer later if needed codex.wordpress.org/Class_Reference/wpdb'fields' => 'ids',
inget_posts
to get only post ID. This is all you need and it will significantely speed up your querywp_cron()