Query terms with Range filter

I get all the brands by:

var_dump(get_terms(‘yith_product_brand’));

and that results:

array (size=10)
0 =>
object(WP_Term)[1484]
public ‘term_id’ => int 17
public ‘name’ => string ‘Apple’ (length=5)
public ‘slug’ => string ‘apple’ (length=5)
public ‘term_group’ => int 0
public ‘term_taxonomy_id’ => int 17
public ‘taxonomy’ => string ‘yith_product_brand’ (length=18)
public ‘description’ => string ” (length=0)
public ‘parent’ => int 0
public ‘count’ => int 8
public ‘filter’ => string ‘raw’ (length=3)
1 =>
object(WP_Term)[1485]
public ‘term_id’ => int 131
public ‘name’ => string ‘Huawei’ (length=6)
public ‘slug’ => string ‘huawei’ (length=6)
public ‘term_group’ => int 0
public ‘term_taxonomy_id’ => int 131
public ‘taxonomy’ => string ‘yith_product_brand’ (length=18)
public ‘description’ => string ” (length=0)
public ‘parent’ => int 0
public ‘count’ => int 5
public ‘filter’ => string ‘raw’ (length=3)
2 =>
object(WP_Term)[1481]
public ‘term_id’ => int 129
public ‘name’ => string ‘Infinix’ (length=7)
public ‘slug’ => string ‘infinix’ (length=7)
public ‘term_group’ => int 0
public ‘term_taxonomy_id’ => int 129
public ‘taxonomy’ => string ‘yith_product_brand’ (length=18)
public ‘description’ => string ” (length=0)
public ‘parent’ => int 0
public ‘count’ => int 5
public ‘filter’ => string ‘raw’ (length=3)

Now I want to query the associated metadata of this taxonomy so I only get the brands which lies under a specific price range which is in wp_postmeta, so I am using the meta query like this:

$args = array(
‘taxonomy’ => ‘yith_product_brand’,
‘meta_query’ => array(
array(
“key” => “_price”,
“value” => 14000,
“compare” => “<”
)
)
);

I was hoping it should have returned me with all the brand names which have items with price less than 14000. What am I doing wrong here?

Read more here:: Query terms with Range filter

Leave a Reply

Your email address will not be published. Required fields are marked *