WordPress Database – Delete Orphaned Posts

Byq292u

WordPress Database – Delete Orphaned Posts

Delete Orphaned Posts

After manually using SQL to delete users, you can be left with (potentially a lot) of posts which now belong to users who simply don’t exist. You don’t want this, it wastes space and clogs things up.
There are two solutions to this:

  1. Delete the Orphaned Posts
  2. Assign them to another user.

I’m going to use option1, as I deleted those users for a reason – Spamming!

From PLESK or CPANEL database web admin:

Delete Orphaned Posts

DELETE
FROM `wp_posts`
WHERE post_author NOT
IN (
SELECT id
FROM wp_users
);

NONE of my tables have a wp_ prefix!

Now DELETE ORPHANED POSTMETA..

** BACKUP YOUR DATABASE FIRST!

Please note: You should NEVER leave your tables with the default “wp_” prefix. Or have a user called “admin”, or a user with id=1. That’s just for start!
Let us secure your WordPress site for you:
http://www.q292u.com/services/secure-your-wordpress-site-our-new-fiverr-gig

About the author

q292u administrator

q292u Has been involved in Computing for more years than he'll admit to. Very active in e-commerce, (eBay, Amazon FBA etc) and has been running Wordpress sites for many years. Always on the lookout for new opportunities. My day job is as IT Business Services Analyst, specialising in IFS ERP systems. Really. Oracle Database admin as well..

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.