$tax_query = array(
        array(
            'taxonomy' => 'category',
            'field' => 'id',
            'terms' => $ajs_cat,
        )
    );

    $args = array(
        'post_type' => 'post',
        'orderby' => 'menu_order',
        'posts_per_page' => $per_page,
        'paged' => $paged,
        'tax_query' => $tax_query,
        'meta_query'    => array(
            'relation'      => 'OR',
            array(
                'key'       => 'price_min',
                'value'     => array($min_price, $max_price),
                'type'      => 'NUMERIC',
                'compare'   => 'BETWEEN'
            ),
            array(
                'key'       => 'price_max',
                'value'     => array($min_price, $max_price),
                'type'      => 'NUMERIC',
                'compare'   => 'BETWEEN'
            ),
        )
    );

I am trying to return acts based on a searched budget minimum (price_min) and maximum (price_max).

So if act ‘X’ has a minimum fee of 3000 (price_min) and a maximum fee of 6000 (price_max)

Search A: (‘X’ is in results)

I search with a budget of minimum of 3000 ($min_price) and a maximum of 5500 ($max_price) i get ‘X’ returned in the results.

Search B: (‘X’ is not in results)

I search with a budget of minimum of 3500 ($min_price) and a maximum of 5500 ($max_price) i would expect to see ‘X’ returned in the results as i could still afford him given my budget.

I need ‘X’ to return in both instances

Could someone help point me in the right direction?

Read more here: Complex Meta Query not returning wanted results


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: