Patrick's Programming Blog

Delete Orphaned Post Meta Data in WordPress

Sometimes while developing a new plugin you have to do lots of database work including creating posts, editing posts, and deleting posts. All of these actions affect the post meta data table and if you aren't careful with how to manage the post meta data you'll have thousands and thousands of rows of data. By deleting orphaned post meta data (meta data belonging to posts which no longer exist) you immediately remove thousands of records that weren't doing anything.

SQL Query

There are plenty of other solutions but beware that some of them might delete your entire table! Make sure you back everything up before you execute any of these.

Exit mobile version