Categories
Wordpress

Deleting wordpress posts

Running wp_delete_post($postId,true); for every post could take serious amount of time. If you need to delete everything let’s say from post _id>320 and category equals to some_category, then this is much more faster solution:

(run mysql commands from phpmyadmin or somewhere,

DELETE from wp_posts WHERE ID>320
DELETE from wp_postmeta WHERE post_id>320
DELETE from wp_terms WHERE term_id>1
DELETE from wp_term_relationships WHERE object_id>320
DELETE from wp_term_taxonomy WHERE taxonomy like 'some_category'

One reply on “Deleting wordpress posts”

Leave a Reply

Your email address will not be published. Required fields are marked *