Last Updated: February 25, 2016
·
3.956K
· clawfire

sql query to delete orphaned post meta in your WordPress database

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.

DELETE pm
FROM wp_postmeta pm
LEFT JOIN wp_posts wp ON wp.ID = pm.post_id
WHERE wp.ID IS NULL

Source