I know that using an underscore in front of a custom field name hides it from display on the front-end, e.g. _custom_field_name
. In my experience, WordPress also prevents one from adding such a custom field on the front end.
Before I go spelunking around core, I wanted to ask: Is there an “easy” way to allow _custom_fields
to be added from wp-admin/post.php?
The reason is this: we rely on hidden custom fields, but when troubleshooting production issues in prod it would be useful to be able to inject certain hidden post meta. I’m not a fan of touching the production database by hand.
I found the following filter, here unlocking all protected meta data:
Or it can be fine tuned:
It allows to display the meta data as well as insert new ones (globally or fine-tuned).
Custom fields that begin with an underscore are hidden from the editor. This is so other methods can access them, but they will not show up as “custom fields”. For example, this is how most Custom Fields plugins work.
http://codex.wordpress.org/Function_Reference/add_post_meta#Hidden_Custom_Fields
If you wish to bypass this, you should be able to:
http://www.wpbeginner.com/wp-tutorials/how-to-show-hidden-custom-fields-in-wordpress/