get_search_formfilter-hookWP 2.7.0

Allows you to change the HTML of the search form.

Usage

add_filter( 'get_search_form', 'wp_kama_get_search_form_filter', 10, 2 );

/**
 * Function for `get_search_form` filter-hook.
 * 
 * @param string $form The search form HTML output.
 * @param array  $args The array of arguments for building the search form. See get_search_form() for information on accepted arguments.
 *
 * @return string
 */
function wp_kama_get_search_form_filter( $form, $args ){

	// filter...
	return $form;
}
$form(string)
The search form HTML.
$args(array)
An array of arguments for building the search form. See the parameter of get_search_form().

Examples

#1 Add custom code before and after the search form

function wrap_search_form( $form ) {
	$before_form = '<div class="block-1">Any content before the search form</div>';
	$after_form  = '<div class="block-2">Any content after the search form</div>';

	return $before_form . $form . $after_form;
}

add_filter( 'get_search_form', 'wrap_search_form' );

Changelog

Since 2.7.0 Introduced.
Since 5.5.0 The $args parameter was added.

Where the hook is called

get_search_form()
get_search_form
wp-includes/general-template.php 359
$result = apply_filters( 'get_search_form', $form, $args );

Where the hook is used in WordPress

Usage not found.