Search for Orphaned Post Meta Data

,

Here is a SQL statement that allows you to search the database for orphaned post meta data. So it looks for any meta data that no longer has a corresponding post in the posts table.

SELECT pm.meta_id, pm.post_id FROM wp_postmeta as pm  LEFT JOIN wp_posts as p ON pm.post_id = p.ID WHERE p.ID IS NULL

 

Skills

Posted on

July 20, 2021

Submit a Comment

Your email address will not be published. Required fields are marked *