Hi Toolset
I just wanted a quick bit of advice on what the consequences are of removing a custom field, if data has already been entered in to it.
Thinking in database terms, I want to perform the equivalent of deleting a column in a table. So I'm imagining this to be the same as deleting a custom field in a custom post type. If I just delete the custom field, do I have to do any "clean up" operations on the database with SQL or should I perhaps even do this before I remove the custom field?
Or is it safe just to delete the custom field, and Toolset will automatically remove all data from that field from all records in the database? What is the expected behaviour?
Thanks and regards
Simon
Hi Simon,
Deleting a custom field from its field group (WP Admin -> Toolset -> Custom Fields) won't delete its existing records in the database.
To delete those records, you can first remove the custom field from its field group and then delete that abandoned field from the "Post Field Control" section.
( you'll see its button at the bottom of the custom fields groups management screen at WP Admin -> Toolset -> Custom Fields )
Example screenshot 1: hidden link
Example screenshot 2: hidden link
regards,
Waqar
Hey Waqar
Thanks for the update. I was more asking about what happens to any data that was entered in that field. Does the data also get deleted from wp_post_metadata if that field is deleted?
In other words, once a field is deleted, does Toolset take care of the deleted data in all records where data was present for that field?
Thanks and regards
Simon
Thanks for writing back and I apologize if my last message wasn't clear.
For better understanding, let's break down the process of deleting a custom field into two main steps:
1. Removing the custom field:
When you'll remove a custom field from its custom field group, it will be removed from the relevant post/page edit screen. However, this field's data (i.e. individual entries in the "wp_postmeta" table) in the database won't be deleted.
2. Deleting the custom field data:
When you'll delete that custom field from the "Post Field Control" section (as explained in my last reply), Toolset will remove that field's data (i.e. individual entries in the "wp_postmeta" table) from the database too.
I hope this makes it more clear.
Hi Waqar
Thanks for the clarification. So the step you mention in step 2 would be the equivalent of deleting the column in a database then, so that there is no trace of any data left over.
Thanks and regards
Simon
> So the step you mention in step 2 would be the equivalent of deleting the column in a database then, so that there is no trace of any data left over.
- Yes, that is absolutely correct.
OK, great. Thanks again, Waqar!
My issue is resolved now. Thank you!