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
:
<?php
$the_posts = new WP_Query( array(
'meta_key' => 'price',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'price',
'value' => '100',
'type' => 'NUMERIC',
'compare' => '>='
)
)
));
?>
<?php while ( $the_posts->have_posts() ) : $the_posts->the_post(); ?>
<h1><?php the_title(); ?></h1>
<?php endwhile; wp_reset_query(); ?>