Field :: meta_key

A field used for searching posts by post meta.

Parameters

label
(string)
Default: None
format
(string) 'select', 'multi-select', 'checkbox', 'radio', 'text', 'hidden', 'number', 'color', 'url', 'email', 'tel', 'date', 'datetime', 'time', 'week'
Default: select
meta_key
(string) (required)
Default: None
values
(array) (required)
Default: None
compare
(string) '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN', 'EXISTS', 'NOT EXISTS'
Default: '='
data_type
(string) 'CHAR', 'NUMERIC', 'ARRAY','BINARY', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED'
Default: 'CHAR'
default
(string)
Default: None

Note: If you are using checkbox or multi-select format with a meta_key field, you must set ‘compare’ => ‘IN’ in order for the search to work. Alternatively, if your meta_key was created using the Advanced Custom Fields plugin you need to use:

'compare' => 'LIKE',
'data_type' => 'ARRAY<CHAR>'

See the WP_Query documentation for more information.