模板标签-the_search_query()

0条评论

说明

如果有查询请求,该标签显示当前请求的查询语句。

可在HTML属性(见下文中的“搜索框”示例)中放心使用该标签。

用法

 <?php the_search_query(); ?> 

示例

在搜索框中显示查询语句

如果你刚刚执行一次搜索,可以在搜索框中显示最近的查询语句。

<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>

在结果页面显示查询语句

你可以在搜索结果页面显示查询字符串。

<p>You searched for \"
<?php the_search_query() ?>
\". Here are the results:</p>

注释

发表新评论

此内容将保密,不会被其他人看见。
  • 自动将网址与电子邮件地址转变为链接。
  • 允许HTML标签:<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • 自动断行和分段。

更多关於格式化选项的信息

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.