函数原型
get_search_query( bool $escaped = true ): string
函数描述
Retrieves the contents of the search WordPress query variable.
是否弃用
未弃用
函数参数
-
$escaped
bool
Optional - Whether the result is escaped.
Only use when you are later escaping it. Do not use unescaped.Default:
true
函数返回值
string
函数位置
File: wp-includes/general-template.php.
函数源码
function get_search_query( $escaped = true ) {
/**
* Filters the contents of the search query variable.
*
* @since 2.3.0
*
* @param mixed $search Contents of the search query variable.
*/
$query = apply_filters( 'get_search_query', get_query_var( 's' ) );
if ( $escaped ) {
$query = esc_attr( $query );
}
return $query;
}
源码链接
变更日志
| Version | Description |
|---|---|
| 2.3.0 | Introduced. |

