WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

what i get

share|improve this question
Post your code, please. For what is worth, I don't recall ever having trouble inserting keys with leading underscores. – s_ha_dum Oct 2 '13 at 18:43
Where are you wanting to inject hidden custom fields? On the Editor page or when the post is displayed to the user? – Charles Clarkson Oct 2 '13 at 19:02
Post my code? There is none relevant to the question. If I'm wrong, my apologies. Re-testing now. @CharlesClarkston exactly, via wp-admin/post.php?post={$ID}&action=edit – editor Oct 2 '13 at 19:58
@s_ha_dum updated to show what I see when trying to add a custom field. – editor Oct 2 '13 at 20:01
What do you mean by front end? Because it doesn't really seem relevant to this question. The front end is the template, as output by the browser. In that context, post meta data are all the same. – Chip Bennett Oct 2 '13 at 21:50
up vote 5 down vote accepted

I found the following filter, here unlocking all protected meta data:

add_filter( 'is_protected_meta', '__return_false' ); 

Or it can be fine tuned:

add_filter( 'is_protected_meta', function( $protected, $meta_key, $meta_type )
    $allowed = array( '_edit_lock', '_test', '_wp_page_template' );
    if( in_array( $meta_key, $allowed ) )
        return false;

    return $protected;
}, 10, 3 );

It allows to display the meta data as well as insert new ones (globally or fine-tuned).

share|improve this answer
Thank you good sir! That got way complicated, fast. – editor Oct 2 '13 at 23:38

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.


If you wish to bypass this, you should be able to:


share|improve this answer
"I know that using an underscore in front of a custom field name hides it from display on the front-end." Sorry, I tried to cover this but must not have been clear enough in my question: What I'm looking for is the ability to leave them hidden for display while allowing them to be added from the "add new" Custom Fields interface. – editor Oct 2 '13 at 20:37
@editor - You should have added this clarification to the Question, I answered without this info... Anyway, I think you cannot have both. . . . GhostToast - that CSS trick ain't working on my side, but even if it did I think it wouldn't suffice. – brasofilo Oct 2 '13 at 21:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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