[wp-trac] [WordPress Trac] #49553: Add option to get_search_form() to not include current search query in the form

WordPress Trac noreply at wordpress.org
Sat Feb 29 22:39:50 UTC 2020


#49553: Add option to get_search_form() to not include current search query in the
form
-------------------------+--------------------------------------
 Reporter:  joelhardi    |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Formatting   |    Version:  trunk
 Severity:  normal       |   Keywords:  has-patch needs-feedback
  Focuses:  template     |
-------------------------+--------------------------------------
 This is a minor enhancement that adds a new option to the argument array
 of `get_search_form()`. The new option would enable the user/theme
 developer to easily output a search form either **with** (this is the
 current function) or **without** the current search query prepopulated in
 the `<input>` field of the search form. Right now there is no easy way to
 include an always-empty search form in a template. For example, the user
 might prefer to have a regular/empty search box in a sidebar or other
 secondary location.

 In the patch I've added a `'show_query'` option that defaults to `true`.

 So when the template calls `get_search_form(array('show_query' => false))`
 then the search form is output with an empty `<input>` field. (And
 `get_search_query()` is not called.)

 There is no change in function when a template calls `get_search_form()`
 and doesn't include this new option, so there's no impact on existing
 templates.

 Thanks for considering this enhancement!

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/49553>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list