WordPress: Template Tags/the search query:修订间差异
来自站长百科
(新页面: == Description == Displays the search query for the current request, if a search was made. This function can be used safely within HTML attributes (as in the "search box" example, below...) |
无编辑摘要 |
||
第1行: | 第1行: | ||
== Description == | == Description == | ||
== 描述== | |||
Displays the search query for the current request, if a search was made. | Displays the search query for the current request, if a search was made. | ||
如果有搜索的话,显示当期请求的搜索查询。 | |||
This function can be used safely within HTML attributes (as in the "search box" example, below). | This function can be used safely within HTML attributes (as in the "search box" example, below). | ||
可以在HTML属性中安全地使用这个标签(如在下面例子中的"搜索框"中)。 | |||
== Usage == | == Usage == | ||
%%% <?php the_search_query(); ?> %%% | %%% <?php the_search_query(); ?> %%% | ||
== 用法 == | |||
%%% <?php the_搜索_查询(); ?> %%% | |||
第14行: | 第23行: | ||
=== Show search query in search box === | === Show search query in search box === | ||
== 例子 == | |||
=== 在搜索框中显示搜索查询=== | |||
If you have just performed a search, you can show the last query in the search box: | If you have just performed a search, you can show the last query in the search box: | ||
如果你刚刚执行了一个搜索,你可以在搜索框中显示最后的查询: | |||
<pre><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></pre> | |||
<pre><form method="get" id="searchform" action="<?php bloginfo('url'); ?>/"> | <pre><form method="get" id="searchform" action="<?php bloginfo('url'); ?>/"> | ||
第25行: | 第47行: | ||
=== Show search query in results page === | === Show search query in results page === | ||
=== 在结果网页中显示搜索查询 === | |||
You can display the search string on search result pages | You can display the search string on search result pages | ||
在搜索结果的网页上,你可以显示搜索字符串 | |||
%%% <p>You searched for " | %%% <p>You searched for " | ||
<?php the_search_query() ?> | <?php the_search_query() ?> | ||
". Here are the results:</p>%%% | ". Here are the results:</p>%%% | ||
%%% <p>You searched for " | |||
<?php the_搜索_查询() ?> | |||
"。这里是结果:</p>%%% | |||
== Related == | == Related == | ||
第38行: | 第66行: | ||
{{PHP Function Tag Footer}} | {{PHP Function Tag Footer}} | ||
== 相关的 == | |||
* [[WordPress:Function_Reference/get_search_query|得到_搜索_查询]] 函数 | |||
* <var>得到_搜索_查询</var> [[WordPress:Plugin_API/Filter_Reference|filter]] | |||
{{PHP函数 标签 页底文字}} |
2008年7月3日 (四) 17:22的版本
Description
描述
Displays the search query for the current request, if a search was made.
如果有搜索的话,显示当期请求的搜索查询。
This function can be used safely within HTML attributes (as in the "search box" example, below). 可以在HTML属性中安全地使用这个标签(如在下面例子中的"搜索框"中)。
Usage
%%% <?php the_search_query(); ?> %%%
用法
%%% <?php the_搜索_查询(); ?> %%%
Examples
Show search query in search box
例子
在搜索框中显示搜索查询
If you have just performed a search, you can show the last query in the search box:
如果你刚刚执行了一个搜索,你可以在搜索框中显示最后的查询:
<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>
<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>
Show search query in results page
在结果网页中显示搜索查询
You can display the search string on search result pages 在搜索结果的网页上,你可以显示搜索字符串
%%%
You searched for " <?php the_search_query() ?> ". Here are the results:
%%% %%%
You searched for " <?php the_搜索_查询() ?> "。这里是结果:
%%%
Related
- get_search_query function
- get_search_query filter