Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have three drop down menus that are chained together. Year, Make Model. I need wordpress search results to show their matching results. If I give them all the name="s" then it only searches the final s= in the url.

I basically need to know how to make

mysite.com/?s=2001&s=Chevrolet&s=Express&Search=Search

turn into:

mysite.com/?s=2001+Chevrolet+Express&Search=Search

or whatever gets the job done.

Any suggestions?

share|improve this question
add comment

1 Answer

You should be using different variables in your URL query, such as:

mysite.com/?year=2001&make=Chevrolet&model=Express

Make sure the name="" in your select inputs reflect the name changes. You will then just need to read in the variables using PHP's $_GET or $_REQUEST global variable. Something like this

$year = ($_GET['year']) ? $_GET['year'] : false;
$make = ($_GET['make']) ? $_GET['make'] : false;
$model = ($_GET['model']) ? $_GET['model'] : false;

You can then use the $year, $make, $model variables in your query if they are not false.

Make sure you also do the proper escaping and filtering of the $_GET variables as well, for security reasons.

share|improve this answer
    
Where does the code you supplied go exactly? I'm a little confused... –  dean Mar 19 '12 at 21:00
    
It can go at the top of the search page template (searchpage.php). Once you submit the form, it will goto the mysite.com/?year=2001&make=Chevrolet&model=Express address. Then the top of the search page template you can include that code. Then you can have logic that determines if any of those variables is set, and if it is you can modify the Query to include filtering by the meta value. –  Dave Hunt Mar 19 '12 at 21:40
    
nice.. thanks man –  Sagive SEO Mar 19 '12 at 21:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.