get_search_form

Definition:
function get_search_form($echo = true) {}

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 ‘get_search_form’.

Parameters

  • boolean $echo: Default to echo and not return the form.

Defined filters

  • get_search_form
    apply_filters('get_search_form', $form)
  • get_search_form
    apply_filters('get_search_form', $form)

Defined actions

  • get_search_form
    do_action( 'get_search_form' );

Source code

function get_search_form($echo = true) {

	do_action( 'get_search_form' );



	$search_form_template = locate_template('searchform.php');

	if ( '' != $search_form_template ) {

		require($search_form_template);

		return;

	}



	$form = '<form role="search" method="get" id="searchform" action="' . esc_url( home_url( '/' ) ) . '" >

	<div><label class="screen-reader-text" for="s">' . __('Search for:') . '</label>

	<input type="text" value="' . get_search_query() . '" name="s" id="s" />

	<input type="submit" id="searchsubmit" value="'. esc_attr__('Search') .'" />

	</div>

	</form>';



	if ( $echo )

		echo apply_filters('get_search_form', $form);

	else

		return apply_filters('get_search_form', $form);

}

1673

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: