i have a custom search which will have 3 inputs (dropdowns) , the html code of the form is ready and will use GET in url , now the remaining part is using values from url to run query. Parameters will be : category, tag and custom field So far i have managed getting the value in url , quering it get post by custom post type category using this code :
$args=array( 'post_type' => 'tyre', 'post_status' => 'publish', 'tax_query' => array( array( 'taxonomy' => 'tyre-category', 'field' => 'ID', //can be set to ID 'terms' => $catid //if field is ID you can reference by cat/term number ) ) );
Till here i managed to pull out the items in the category of custom post.
Now the remaining part will be check two custom fields and if the value matches as in parameter in url then display. how will be able to do that i am not sure how to modify the loop for that.
I have Managed 90% of it by using meta_query code below :
'meta_query' => array( 'relation' => 'AND', array( 'key' => 'size', 'value' => $size, 'compare' => '=' ), array( 'key' => 'terrain', 'value' => $terrain, 'compare' => '=' ) )
Now the only problematic part is extracting and check value from a custom field called size, as it can have comma seperated multiple sizes.
Help is Appreciated! Thanks and Regards