Greetings!
Need some help with making simple search form using one custom field and it's value.
I have:
1) Form code in sidebar:
<form action="page-customsearch.php" method="get">
<label><h5>Search by price</h5></label>
from <input type="text" name="min-price" size="10" value="" style="width:35%;" />
to <input type="text" name="max-price" size="10" value="" style="width:35%;" />
<input type="submit" value="Search" />
</form>
2) Code in "page-customsearch.php":
<?php $args = array(
'post_type' => 'project',
's' => $_GET['word'],
'meta_key' => $_GET['meta_key'],
'posts_per_page' => $_GET['num'],
'paged' => get_query_var( 'paged' ),
'order' => $_GET['order'],
'orderby' => $_GET['orderby'],
'tax_query' => array(
array(
'taxonomy' => 'proekty',
'field' => 'id',
'terms' => array($_GET['proekty'])
)
),
'meta_query' => array(
array(
'key' => 'project_price',
'value' => array( (int)$_GET['min-price'], (int)$_GET['max-price'] ),
'type' => 'numeric',
'compare' => 'BETWEEN'
)
)
);
query_posts( $args ); ?>
More info:
Custom field name - "project_price"
Custom fied value - "500000"
Single product page with custom field(price) named - "single-project.php"