Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am somewhat new to WordPress. 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
    

1 Answer 1

up vote 4 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

 
discard

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.