0

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.

0

If you are new and confused then please follow these link

https://stackoverflow.com/questions/11068795/wordpress-get-post-based-on-meta-field-content

And

https://rudrastyh.com/wordpress/meta_query.html

May be These may help You.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.