lundi 2 février 2015

how to create advanced search


I'm really stuck in this and i cant find any tutorial or article about this topic.


How about if we have this pattern for search:



[country] AND [category1 OR category2] AND [city1 OR city2] AND [title]
[-radio-] AND [------Checkboxes------] AND [--Checkboxes--] AND [radio]


ok, my code is here. It doest work


html:



<input name="location" value="country_one" type="radio" /> Country 1
<input name="location" value="country_two" type="radio" /> Country 2
<input name="location" value="country_three" type="radio" /> Country 3

<input name="venueA" type="checkbox" value="A" /> selectA
<input name="venueB" type="checkbox" value="B" /> selectB
<input name="venueC" type="checkbox" value="C" /> selectC


functions.php



$metaArgs = array('relation' => 'AND',

array( 'key' => 'location',
'value' => $country,
'compare' => '=='
),

array('relation' => 'OR',
array( 'key' => 'venue',
'value' => $venueA,
'compare' => '=='
),
array( 'key' => 'venue',
'value' => $venueB,
'compare' => '=='
),
array( 'key' => 'venue',
'value' => $venueC,
'compare' => '=='
)
)
);



$query->set( 'meta_query' , $metaArgs );




Aucun commentaire:

Enregistrer un commentaire