WordPress.org

Make WordPress Core

Opened 14 months ago

Last modified 14 months ago

#49553 new enhancement

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

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

Description

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 14 months ago.
proposed path to add show_query option to get_search_form()

Download all attachments as: .zip

Change History (3)

@joelhardi
14 months ago

proposed path to add show_query option to get_search_form()

#1 @SergeyBiryukov
14 months ago

  • Component changed from Formatting to Themes

#2 @SergeyBiryukov
14 months ago

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