Languages: English • 日本語 (Add your language)
The search query string is passed through esc_attr() to ensure that it is safe for placing in an html attribute. This function is used to get the query string when a user performs a search on the site. It returns the query string rather than display it; to display the query, you can use the_search_query().
<?php $search_query = get_search_query(); ?>
Examples of the different usage methods.
<?php echo get_search_query(); ?> <?php $search_query = get_search_query(); ?>
since 2.3.0
get_search_query()
is located in wp-includes/general-template.php
.