
Existing Custom fields are visible and editables when you edit a post. But when the custom field is created by a piece of code, you may not want to display it publicly. Here is how to do.

Existing Custom fields are visible and editables when you edit a post. But when the custom field is created by a piece of code, you may not want to display it publicly. Here is how to do.
This little trick is extremely simple: All you have to do is give a name starting with an underscore to your custom field when you create it, and it will not be displayed on WordPress dashboard when editing a post, as shown in the example below:
add_post_meta($id, '_name', 'value');
Easy, isn't it? And of course, very useful
Thanks to my friend John Kolbert for the tip!
20 Responses
Awesome! It’s so simple. I’m searching this for a long time. Thank you very much.
Don’t get the point. Could you give an example?
Same here – I don’t get it either. Please explain a little bit further the reason behind this code.
Nice tutorial, I love how this blog will write a tutorial for even the smallest of things!
What I think this does @Florian + @FreewareMatter is creates a custom field you can use in a post, but it won’t show up in the dropdown box on the post screen. So, I guess if you let guest posters or someone in the Admin Pane you don’t want to use the custom field, then this code won’t let them see it for use.
At least I think that’s what it’s for.
So if you don’t see it, how to use it?
Ya! this is really imformative code for wordpress user.
Hey guys. I wrote the original tutorial, so let me elaborate. One way this could be useful is for plugin authors who create their own input boxes in the write post/page screens that interact with custom fields. For example, the Market Theme adds input fields for price, shipping, etc. that store their values as custom fields. By naming the custom field with the underscore it wouldn’t show up in WordPress’ custom fields editing box, but would show up in the input boxes created by the theme. It avoids the confusion of having the same info in two locations.
Thanks John for the explanation. It was for those who loves to customize input fields and protecting them..err hiding them from wp system.
Every time i try to put the code in either my post or my text widget it just comes up blank, it won’t show anything. Now widgetbucks say that you can post the code on your wordpress blog. However i am having issues doing so. Can someone please helpme and/or give me some tips.
Plz let me know how u get it implement. Becoz I’m not getting it properly..
What does this do actually?
So simple and awesome..
Now that IS handy, I’m still fairly new to WP development but I’m doing a lot of theme customisation for various projects at the moment. This is a useful tip, thanks.
You right this is very easy! Nice and simple a great little trick. Its rare to see something that is both useful and easily done. That’s for the tutorial, and also for the explanation John!
Till then,
Jean
Oh boy, let’s think, guys!
It’s useful specially when we have guest writers and they won’t be able to guess or use custom fields.
Its also handy to hide the fields you have been using in other posts – since wordpress stores it in a drop-down list.
All clear?
simple but very usefull, thanks for the tips
The developer I work with was trying to customize a plugin that touched on this and was looking for the best way to customize the look and feel of that link. This post was very helpful, I have already passed it along.
Absolutely SUPERB! Excellent tip there.. Will definitely come in handy!
Trackbacks: