the_search_query

Sponsored Link

検索が行われた場合に、現在のリクエストの検索クエリーを表示します。

この関数は、HTML属性(以下の”検索ボックス”の例のように)内で安全に使用する事が出来ます。
get_search_queryの値を取得するために使用します。

Sponsored Link

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

Use get_search_query to retrieve the value.

the_search_queryのテンプレートタグ使用方法

<?php the_search_query(); ?> 

検索ボックス内に検索クエリーを表示する方法

検索を実行した場合、検索ボックス内に最後のクエリーを表示する事が出来ます。

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>

結果ページに検索クエリーを表示する方法

検索結果ページに検索文字列を表示する事が出来ます。

You can display the search string on search result pages

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

注釈

  • Uses: get_search_query()
  • Filter: get_search_query
Sponsored Link