Display search form.

Will first attempt to locate the searchform.php file in either the child or the parent, then load it. If it doesn’t exist, then the default search form will be displayed. The default search form is HTML, which will be displayed. There is a filter applied to the search form HTML in order to edit or replace it. The filter is {@see ‘get_search_form’}.

This function is primarily used by themes which want to hardcode the search form into the sidebar and also by the search widget in WordPress.

There is also an action that is called whenever the function is run called,


get_search_form( $echo = true )
 (boolean) Default to echo and not return the form.
Default: true


(string|void) String when $echo is false.


function get_search_form( $echo = true ) {
	 * Fires before the search form is retrieved, at the start of get_search_form().
	 * @since 2.7.0 as 'get_search_form' action.
	 * @since 3.6.0
	 * @link https://core.trac.wordpress.org/ticket/19321
	do_action( 'pre_get_search_form' );

	$format = current_theme_supports( 'html5', 'search-form' ) ? 'html5' : 'xhtml';

	 * Filters the HTML format of the search form.
	 * @since 3.6.0
	 * @param string $format The type of markup to use in the search form.
	 *                       Accepts 'html5', 'xhtml'.
45 more lines...
WP Trac GitHub

Link here