The default WordPress ‘Posts’ post type has a section called Custom Fields that greatly increases the extensibility of WordPress. Many plugins and themes make use of the custom fields to hold extra metadata about a post or display special information. If you have installed and deleted plugins before or even mistyped the name of a custom field before, those entries can keep coming back for future entries. It might just be an annoyance or it could be a source of confusion. Here’s how to bulk delete custom fields that you no longer want taking up space in your site’s database.
The custom field list is generated by looking at custom fields used in previous posts. If you want to delete a name, you will need to delete the value from any posts that have it entered. For one or two, that can be easy if you catch it right away but for those generated by a plugin or in many posts, it can be time consuming to go through each post. You could alternatively use phpMyAdmin to go through the wp_postmeta table to search for the fields of the custom fields you wish to delete.
An easier way comes by means of a plugin. Using the Delete Custom Fields plugin (install and activate it on your WordPress site), you can find it under Tools -> Delete Custom Fields. It will show you all the custom fields in your database, optionally including hidden field names (they start with an underscore ‘_’ ). You can then just select the custom field you want to get rid of from the drop-down and hit ‘Delete Permanently’ button.
The action will take you to a report where you can watch it progress through your previous posts, deleting the custom fields you selected.
Very easily, you can clean up any old custom fields you no longer need. Be careful! Make sure you don’t delete any field names that are currently being used by your plugins or themes. There’s no way to recover the data with this tool once they’re deleted.
It would be nice if this plugin could just generate a list of posts with a specific custom field name without starting the delete process. It would help trying to figure out those custom fields that have generic names that you can’t remember what plugin created them. For now, I guess that task will be left to diving into the database with phpMyAdmin.