One of the joys of Wordpress is that it is common for inactive plugins to leave old data in the database. That includes a lot of custom fields. So some people look to delete custom field data from the database.
The plugin might be long gone and not even there anymore, but the custom fields it creates are left behind and just sitting there. And depending on how old your site is or how many plugins you’ve used in the past, you could end up with a lot of custom field data just sitting there doing nothing.
Wordpress has no built-in way to remove custom field data. I wish it were there, but I also understand that such functionality could lead to people inadvertently hurting their site. They probably left it out for safety purposes.
Plus, the truth is that it doesn’t really hurt anything for that data to sit there in the database.
A lot of people think they’re going to speed up their sites in a noticeable way by removing this custom field data from the database. But, the reality is that any effect would be so small that it probably wouldn’t even be noticed. MySQL (the database that Wordpress uses) is incredibly fast and having that data sit there really isn’t going to slow things down.
That said… some people just like the feeling of a fresh slate. 🙂 And I get it.
Now, the usual way of deleting custom field data from Wordpress is to dive into PHPMyAdmin. You go into the database directly, query the data out of the post_meta table by field name, then delete those rows.
But, there is an easier way.
You can use the Edit Custom Fields plugin.
This plugin is simplistic. But, it does the job.
First things first… backup your database!
You are about to delete raw data out of your Wordpress database, so definitely run a backup first. If you end up screwing something up, you will have the ability to reverse the damage.
Once the backup is done, go to Tools > Edit Custom Fields.
You will see a big list of all of your custom fields. They will be listed by the raw field name just as they are stored in the database.
Now, it is up to you to figure out what the purpose of those fields are. In some cases, you can tell just by looking. Most plugins will prefix the field name by the name of the plugin itself. If that’s the case, you can quickly determine if those fields are still in use or not.
If you are in doubt about whether a field is used, you can do 2 things:
- Google the field name and see if you can figure out what plugin put it there. Then, act accordingly.
- Just leave the field alone. As I said, it is doing no harm sitting there so if you’re doubtful abbout the safety of deleting it, just leave it be.
To delete the custom field data, just check off those fields you’d like to delete. Then, scroll down and hit the button to delete those fields.
You will get a confirmation screen that shows the fields you selected as well as a summary of the posts those fields are attached to.
If everything looks OK, hit the button to confirm and permanently delete the fields.
And that’s it. 🙂
You can repeat this process until you delete all the fields you wish to remove.
Keep in mind that this is removing the field DATA. If you used a plugin (like Advanced Custom Fields) to define the field to begin with, this process will not affect that. You would need to delete the fields from there, too.