In WordPress, after creating, editing and deleting your blog posts, your database will contain thousands of rows of useless meta data. If you want to delete orphaned post meta on your database then here is a simple SQL query.
Just run the following query on your WordPress database to delete orphaned post meta. Don’t forget to replace the table prefix wp_ if your database is using another prefix.
And of course, create a backup of your database before running the query!
DELETE pm FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL
Thanks to Patrick Rauland for submitting this useful recipe!
If you enjoyed this article, please consider sharing it!!
The post Sql Query to Delete Orphaned Post Meta in Your WordPress Database! appeared first on WordPress Experts.