How to clean WordPress

Manu shared with me what he wrote to his development team in order to clean WordPress. Here it is:

How to restore the WordPress installation to full health:

  • Do a manual full backup with the plugin BackupBuddy or a different system/plugin.
  • Use the plugin WP Maintenance Mode to enable the maintenance mode. This will serve a static page to everyone, except administrators.
  • Run the plugin WP Clean Up and delete all the drafts – Check if there is any draft that is not a RSS imported post (categorized as ‘imported-photo’).
  • DELETE orphan attachments with the following query:
    DELETE FROM [YOU_DATABASE_NAME].wp_posts
    WHERE post_type = ‘attachment’
    AND post_parent NOT IN (
    SELECT ID FROM (
    SELECT ID FROM [YOU_DATABASE_NAME].wp_posts
    WHERE post_type <> ‘attachment’) as sub_query);
  • Use the plugin Media Cleaner to dispose the ‘Orphan Postmeta’.
  • Run the plugin Media Cleaner to locate and erase the orphan files in the upload folder
  • Disable the maintenance mode.
  • Test everything in incognito mode or in a new browser (so nothing is cached).
  • Double test everything with another computer.
  • Do another manual full backup.

I recommend you to use WPEngine or SiteGround. They are both excellent hosting services and work perfectly with all my plugins.