Making a “Hidden” Custom Field

If you are a plugin/theme developer and you are planning to use custom fields to store parameters related to your plugin or template, it is interesting to note that WordPress won’t show keys starting with an “_” (underscore) in the custom fields list at the page/post editing page or when using the template the_meta() function. Depending on how you plan to use the meta data, you may want to hide the values from the the admin UI by prefixing their names with an underscore.

The following example:

add_post_meta(68, '_color', 'red', true);

will add a unique custom field with the key name “_color” and the value “red” but this custom field will not display in the page/post editing page.

In addition, when $meta_value is an array, it will not be display on the page/post editing page.

via Function Reference/add post meta « WordPress Codex.

Advertisements

10 thoughts on “Making a “Hidden” Custom Field

  1. Homepage says:

    … [Trackback]…

    […] Find More Informations here: iammahmudur.wordpress.com/2012/06/13/making-a-hidden-custom-field/ […]…

  2. … [Trackback]…

    […] Read More here: iammahmudur.wordpress.com/2012/06/13/making-a-hidden-custom-field/ […]…

  3. … [Trackback]…

    […] Read More: iammahmudur.wordpress.com/2012/06/13/making-a-hidden-custom-field/ […]…

  4. … [Trackback]…

    […] Informations on that Topic: iammahmudur.wordpress.com/2012/06/13/making-a-hidden-custom-field/ […]…

  5. website says:

    … [Trackback]…

    […] Informations on that Topic: iammahmudur.wordpress.com/2012/06/13/making-a-hidden-custom-field/ […]…

  6. … [Trackback]…

    […] Informations on that Topic: iammahmudur.wordpress.com/2012/06/13/making-a-hidden-custom-field/ […]…

  7. job seek says:

    … [Trackback]…

    […] Read More: iammahmudur.wordpress.com/2012/06/13/making-a-hidden-custom-field/ […]…

  8. CARRERA TOPCAR 1,http://pinterest.com/pin/165929567491340957/,http://pinterest.com/pin/165929567491340957/ says:

    … [Trackback]…

    […] There you will find 61764 more Infos: iammahmudur.wordpress.com/2012/06/13/making-a-hidden-custom-field/ […]…

  9. tatuaggi says:

    … [Trackback]…

    […] Read More: iammahmudur.wordpress.com/2012/06/13/making-a-hidden-custom-field/ […]…

  10. Real Estate says:

    … [Trackback]…

    […] There you will find 63229 more Infos: iammahmudur.wordpress.com/2012/06/13/making-a-hidden-custom-field/ […]…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: