最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

forms - Wordpress search with more input fields?

programmeradmin4浏览0评论

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)

发布评论

评论列表(0)

  1. 暂无评论