the_search_query() WordPress Function

The the_search_query() WordPress function outputs the contents of the search query variable. This is useful for displaying the search query in the results page.

the_search_query() #

Displays the contents of the search query variable.


Description

The search query string is passed through esc_attr() to ensure that it is safe for placing in an HTML attribute.


Top ↑

Source

File: wp-includes/general-template.php

function the_search_query() {
	/**
	 * Filters the contents of the search query variable for display.
	 *
	 * @since 2.3.0
	 *
	 * @param mixed $search Contents of the search query variable.
	 */
	echo esc_attr( apply_filters( 'the_search_query', get_search_query( false ) ) );
}


Top ↑

Changelog

Changelog
VersionDescription
2.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More