admin管理员组

文章数量:1404927

I have this example of working search:

<form action="<?php echo esc_url(site_url('/')) ; ?>" method="get">
   <input type="search" name"s">
   <input type="submit" value="search">
</form>

and this works great, but what I want to archive is to make this search work with two more select boxes:

<form action="<?php echo esc_url(site_url('/')) ; ?>" method="get">
   <select name="">
       <option>Option one</option>
       <option>Option one</option>
   </select>
   <select name="">
       <option>Option A</option>
       <option>Option B</option>
   </select>
   <input type="search" name"s">
   <input type="submit" value="search">
</form>

How do I go around to make this post do something like this: mysiteDOTcom/s=option1+optionb+searchinput ? Thanks in advance

I have this example of working search:

<form action="<?php echo esc_url(site_url('/')) ; ?>" method="get">
   <input type="search" name"s">
   <input type="submit" value="search">
</form>

and this works great, but what I want to archive is to make this search work with two more select boxes:

<form action="<?php echo esc_url(site_url('/')) ; ?>" method="get">
   <select name="">
       <option>Option one</option>
       <option>Option one</option>
   </select>
   <select name="">
       <option>Option A</option>
       <option>Option B</option>
   </select>
   <input type="search" name"s">
   <input type="submit" value="search">
</form>

How do I go around to make this post do something like this: mysiteDOTcom/s=option1+optionb+searchinput ? Thanks in advance

Share Improve this question asked Dec 28, 2019 at 18:06 ArttyorArttyor 514 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 0

Sorry, it's unclear to me what your goal is, if you could clarify your question more and additional information like what kind of options you're trying to use (are they custom fields, are they categories, tags, or other taxonomies, or another characteristic like post author?)

First, the select inputs should not have blank name values. (visit this a11y guide page for an example of building a search form with select lists as an example although the example is not specific to WordPress.) Having blank name values usually results in errors in a search form.

(Visit for an example search query How do I properly redirect outbound links with special characters)

本文标签: formsWordpress search with more input fields