Make WordPress Core

Opened 4 years ago

Last modified 4 years ago

#49553 new enhancement

Add option to get_search_form() to not include current search query in the form

Reported by: joelhardi's profile joelhardi Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.4
Component: Themes Keywords: has-patch dev-feedback
Focuses: template Cc:


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!

Attachments (1)

49553.diff (2.3 KB) - added by joelhardi 4 years ago.
proposed path to add show_query option to get_search_form()

Download all attachments as: .zip

Change History (3)

4 years ago

proposed path to add show_query option to get_search_form()

#1 @SergeyBiryukov
4 years ago

  • Component changed from Formatting to Themes

#2 @SergeyBiryukov
4 years ago

  • Keywords dev-feedback added; needs-feedback removed
Note: See TracTickets for help on using tickets.