I created a custom field that I would like to hide from the wp-admin (because the system generates it and I don't want user to change it; Hidding it with CSS should be OK in this case),

Like this,

 'postal_address' => array(
                            'guid' => 'postal_address',
                            'control' => array(
                                'type' => 'text',
                                'default' => '',
                                'allow_empty' => false
                            'label' => 'Postal Address',
                            'help'  => 'Postal Address of Apartment'

Wich works,

Problem is that the html element doesn't have any id/class so I can select it and Hide it,

Is there a way to add an html attribute from the definition?


  • 2
    How did you create the custom field? It seems like you might be using a plug-in, if so you might want to say that ;) – Stephen Harris Dec 16 '13 at 19:14
  • YES! true, I should had mention, some reason I thought it would be using standard wp functions anyway, I will rewrite the question.. thanks! – Toni Michel Caubet Dec 16 '13 at 19:23

If you're automatically populating a custom field, you can put an underscore at the beginning of the name ("_postal_address") to hide it in the admin UI.

|improve this answer|||||
  • Hey! thanks for you answer, but in the code I would need to use the '_name' aswell? thanks again (because I have allready many values stored). BTW: Do you mean in the index? or in the GUID attribute? – Toni Michel Caubet Dec 16 '13 at 19:50
  • You should be able to just update the value with update_post_meta(). See codex.wordpress.org/Custom_Fields I don't recognize what your sample code is trying to do, but it looks like it's trying to define a user interface for this field. You won't need that. – Dave Ross Dec 16 '13 at 20:10
  • 1
    @DaveRoss I believe the OP is actually using a plug-in so it's not clear what translates to the meta key. It may not be possible. But when using only core, you're right (although you can use this filter too: github.com/WordPress/WordPress/blob/3.8/wp-includes/…) – Stephen Harris Dec 16 '13 at 23:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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