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

While trying to perform a WP_Query using meta_query(), I had some trouble because the custom fields created by a plugin had _ in the beginning of its name.

Although I noticed it was stored this way in the database, I had no idea why it was there and thought I had to reference it without the underscore (for the record, that is wrong).

Why do some custom fields start with underscores and others don't? What are the underscores used for? Are they mandatory in some circumstances?

share|improve this question
up vote 7 down vote accepted

Custom field names are arbitrary. The underscore hides it from the Custom Fields metabox on the post editing page. When referencing these custom fields in meta_query() or other functions, the underscore has to be used.

Source: conversation with @toscho, @rarst and @wyck in the chat room.

share|improve this answer

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.