In a plugin i developed i created metaboxes in the new/update post page in the admin area that save data into custom fields. In order to prevent confusion or any kind of issues i created those custom fields hidden by adding "_"(underscore) to the beginning of it. Now i realize that other plugins will not recognize those custom fields and not just Wordpress so i am looking for a way to fix that as i want my plugin to be able to work together with other plugins.

Obviously just removing the "_" from the name would be the fast and easy way to go. However, users that will do an update to the plugin will have issues since all their data is already saved in the old custom fields.

One way i was thinking of is adding another set of non hidden custom fields that will hold the same data as the hidden custom fields. so for example if now i have "_address" i will add another fields "address" and whenever the post being saved the data will be saved in both custom fields. This way, users that already have data in the database won't have any problems using it. However, for the same users ( who updating) the data will not be exist in the new custom fields until the post will be saved again. Means that plugins will recognize the new fields but nothing will be there.

So my first question is , does anyone know on of a better way i can archive that?

and if not , how about a function i can add to the plugin that once a user do an update it will automatically run "save" through all the posts in his database so then i guess the data will be saved in the new custom fields ? Or maybe a function that will duplicate all the hidden custom fields in the user's database begins with underscore to custom fields with the same name just without underscore?

[Update - pulled from a Comment]

Well, a quick look into the "post widget" code i found this line "HAVING meta_key NOT LIKE '_%'" which hide hidden custom fields. i guess plugin developers hide it by default.

  • What tests have you made that prove that "other plugins [...] and not just WordPress" don't recognize the hidden CF?
    – brasofilo
    Jul 14, 2012 at 14:09
  • first issue i had (and still having) is with "Quick Post Widget" plugin. the plugin will recognize all custom fields but the hidden ones. And yesterday i got another user saying that he couldn't use the custom fields with another plugin but i did not asked him which one. i guess i can ask.
    – Eyal
    Jul 14, 2012 at 15:09
  • @Eyal that just sounds like an issue of the plugin developer intentionally skipping keys that are prefixed with an underscore. if we think about this logically, there is no way for a plugin to identify what keys belong to it by simply adding an underscore, the whole premise is simply not possible.
    – Milo
    Jul 14, 2012 at 15:16
  • I guess it make sense. i assumed that that was the situation since i got 3 users reporting the issue. i guess i can contact the developer of the "quick post widget" and see. and again, thank you for your advice.
    – Eyal
    Jul 14, 2012 at 15:33
  • Well, a quick look into the "post widget" code i found this line "HAVING meta_key NOT LIKE '_%'" which hide hidden custom fields. i guess plugin developers hide it by default.
    – Eyal
    Jul 14, 2012 at 17:11

1 Answer 1


Prefixing custom fields with an underscore only results in the keys being hidden from the default custom fields UI:

enter image description here There is nothing preventing plugins or theme code from otherwise querying these keys and their values.

  • thank you for your input milo. please see my comment above.
    – Eyal
    Jul 14, 2012 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.