Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm just an basic Wordpress user. I need to make search box with multiple criteria inputs (multiple conditions) to search inside various Custom Fields.

For example including following Custom Fields:

Color: ____
Price: ___
Discount %: ___
Hit Count:

User may input 1 or more fileds.
Result should be filtered for multiple input also.
For example: Price: ____100___ and Condition: ____Fair____
So, how can i handle this multiple conditions in Query?

It is ok for every single inputs.
But, problem with more then 1.
I'm confusing how to write query for multiple criteria (in former way).

A simple sample please.

share|improve this question
Try this – user10874 Dec 5 '11 at 19:09

1 Answer 1

have a look at WP_Query(); and use meta_query / tax_query arguments

$args = array(
    'post_type' => 'product',
    'meta_query' => array(
            'key' => 'color',
            'value' => 'blue',
            'compare' => 'NOT LIKE'
            'key' => 'price',
            'value' => array( 20, 100 ),
            'type' => 'numeric',
            'compare' => 'BETWEEN'
$query = new WP_Query( $args );
share|improve this answer

Your Answer


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.