I have to search for posts that have in tags or custom fields a number(price): example 152. Each post have a price tag. How I do to search for all post greater than a price for example I need to search for all post who have a price tag of minimum 100.
Something like /?s=keyword&price>=300
Thx
If you save the the price in a meta field, you can query posts using
meta_query
:If the price is stored as a custom field you’ll need to use the
meta_query
argument ofWP_Query
(see Codex). For instance:(where
price
is the key of the custom field). Depending on how you might be implementing this (is it intended to be the ‘main query’ or not – you might want to use this atpre_get_posts
)Edit
If filtering a search result:
Note: The original answer had a meta query which specified a range. The second answer has a meta query which filters for prices above some minimum value.
Usage:
/?s=keyword&min=300