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...)
 
 
(未显示2个用户的2个中间版本)
第1行: 第1行:
== 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_search_query(); ?> %%%


== 例子 ==


== Examples ==
=== 在搜索框中显示搜索查询===


=== Show search query in 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'); ?>/">
<pre><form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
第24行: 第22行:
</form></pre>
</form></pre>


=== Show search query in results page ===


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


== Related ==
== 相关的 ==
 
*  [[WordPress:Function_Reference/get_search_query|get_search_query]] 函数


*  [[WordPress:Function_Reference/get_search_query|get_search_query]] function
*  <var>get_search_query</var> [[WordPress:Plugin_API/Filter_Reference|filter]]


{{PHP Function Tag Footer}}
{{PHP函数 标签 页底文字}}

2008年9月16日 (二) 09:46的最新版本

描述[ ]

如果有搜索的话,显示当期请求的搜索查询。

可以在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>


在结果网页中显示搜索查询[ ]

在搜索结果的网页上,你可以显示搜索字符串

%%%

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

%%%

相关的[ ]