Tutorial: How to quickly delete a bunch or unwanted records
Hi,
I have a lot of listings in my Vantage, and sometimes I import listings that dont got in the way I wanted them. I need to delete them, but not so easy to delete thousands of record in
WP backend. You have to bulkedit trash and delete them with maybe max 150 - 400 at a time, which can take time.
I came up with a quick way to do this and I'm now sharing them with you.
If you eg wanna delete all records in DRAFTs, you do the following:
Go your cPanel and phpMyAdmin
Run this sql first for test to see the records (not really necessary, but but)
SELECT b.post_title, b.post_status, a.meta_key, a.meta_value FROM wp_postmeta a, wp_posts b WHERE a.post_id = b.id and b.post_status = 'draft'
Then, run this SQL first to delete the records in wp_postmeta:
DELETE FROM wp_postmeta WHERE post_id IN (SELECT distinct id FROM wp_posts WHERE post_status = 'draft')
Then run this sql to delete the records in wp_posts:
DELETE FROM wp_posts WHERE post_status = 'draft'
Check now in admin>Listings to see and verify that the drafts are gone...
Use the same procedure to delete records from published, private or trash. Just change 'draft' in the SQL with 'publish', 'private' or 'trash'
Pls backup your db before attempting this.