I have made two dropdown list which is a custom fields.
Custom Field 1 :- industry
Values of Custom Field 1 :- financial_services,ecommerce,insurances, etc.
Custom Field 2 :- primary_functionality
Values of Custom Field 2 :- platform_decision_engine,user_authentication,data_provider_verification etc.
And My Post Type Name is :- providers.
Now, I want to fetch posts with multiple custom fields.
So, I have tried this query. But it’s not working.
$args = array(
'numberposts' => -1,
'post_type' => 'providers',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'industry',
'value' => 'financial_services',
'compare' => '='
),
array(
'key' => 'primary_functionality',
'value' => 'platform_decision_engine',
'compare' => '='
)
)
);
Even I tried with for single custom field but it’s also not working.
// args
$args = array(
'numberposts' => -1,
'post_type' => 'providers',
'meta_key' => 'industry',
'meta_value' => 'financial_services'
);
I’m not that much experienced in wordpress. I have read wordpress document but nothing works. I’m confused about relation and compare in this query.