Meta Queries

Get familiar with meta queries for querying multiple custom fields.

Meta refers to additional data associated with a post. Custom fields store additional information or metadata about a post. In the last lesson we looked at meta_key, meta_value and meta_compare parameters.

meta_query

The meta_query parameter is a little different from the other query parameters we have seen so far. This parameter takes a nested array of arguments which specify the metadata. A meta query can be used to check for multiple conditions. For an e-commerce store, one condition can be the size of the product and the other can be the color. For our example, one condition can be the post should belong to a particular month and another condition can be that it should be from a particular category. All the conditions for the query are provided as comma separated arrays.

Get hands-on with 1200+ tech skills courses.