WordPress函数:the_search_query
描述
显示当前请求的搜索查询字符串。
此函数可以在HTML属性安全使用。(参考下面的“搜索框”举例)
使用函数 get_search_query 取回查询字符串。
用法
<? php the_search_query(); ?>
举例
1.在搜索框显示搜索查询。
如果您刚刚进行了搜索,您可以在搜索框中显示最近一次查询字符串:
<form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
<div>
<input type="text" value="<?php the_search_query(); ?>" name="s" id="s" />
<input type="submit" id="searchsubmit" value="Search" />
</div>
</form>
2.在搜索结果页面显示搜索查询。
您可以在搜索结果页面显示查询字符串。
<p>You searched for " <?php the_search_query() ?> ". Here are the results:</p>
原文来自http://www.zhangqi02.com/2012/08/wordpress-function-reference-the_search_query/
