wordpress 函数 get_search_query
描述
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().
(搜索查询字符串通过esc_attr(),以确保它是安全的放置在html属性。这个函数是用于获取查询字符串当用户在网站上执行一个搜索。它返回查询字符串,而不是显示,显示查询,您可以使用the_search_query()。)
用法
<?php $search_query = get_search_query(); ?>
参数
$escaped
(bool) (可选) Whether the result is escaped. Default true. Only use when you are later escaping it. Do not use unescaped.
Default: true
返回
(string) query.
例子
Examples of the different usage methods.
<?php echo get_search_query(); ?> <?php $search_query = get_search_query(); ?>
Changelog
since 2.3.0
Source Code
get_search_query() is located in wp-includes/general-template.php.
Related
See also index of Function Reference and index of Template Tags.
