SearchWP Documentation

インストールガイドを表示したり、ナレッジベースを参照したり、SearchWPの多くのフックについて確認したりできます。

ショートコード

現在のバージョン: 1.8.5

この拡張機能は、SearchWP検索エンジン用の検索フォームと結果ページの両方を生成するショートコードを提供します。検索フォームや結果ループを実装するためにテーマファイルを直接編集することに慣れていない(またはできない)場合に便利です。

ショートコードをアクティブにすると、次のものが利用可能になります。

ショートコード属性
searchwp_search_form

特定の検索エンジンの検索フォームを出力します
target — フォームのアクション(デフォルトは既存のパーマリンク)
engine — 検索エンジンの名前(デフォルトはdefault
var — 検索クエリ変数の名前(デフォルトはswpquery
button_text — フォームボタンのテキスト(デフォルトはSearch
hide_button — 「true」または「false」のいずれか、検索フォームの送信ボタンを非表示にします
placeholder — フォーム入力フィールドのプレースホルダーテキスト(デフォルトはSearch
live_search — 「true」または「false」のいずれか、グローバルな「ライブ検索を有効にする」設定の値を無視して、このフォームのライブAjax検索を強制的に有効/無効にします
searchwp_search_results

検索が送信された後の検索結果のリストを出力します
engine — 検索エンジンの名前(デフォルトはdefault
var — 検索クエリ変数の名前(デフォルトはswpquery
posts_per_page — 1ページあたりの表示投稿数

これは自己終了ショートコードではないことに注意してください。各検索結果のマークアップは内部にネストする必要があります。例については、以下のサンプルを参照してください
searchwp_search_result_link

結果のタイトルのテキストで、現在の検索結果へのリンクを出力します
direct — 「true」または「false」のいずれか。trueの場合、パーマリンクに直接リンクします。添付ファイルの場合は、親ページではなくそのURLに直接リンクします
searchwp_search_result_excerpt

現在の検索結果の抜粋を出力します
なし
searchwp_search_results_none

検索結果が見つからなかった場合の出力
なし

これは自己終了ショートコードではないことに注意してください。各検索結果のマークアップは内部にネストする必要があります。例については、以下のサンプルを参照してください
searchwp_search_results_pagination

検索結果のページネーションを出力します
engine — 検索エンジンの名前(デフォルトはdefault
direction — 「prev」または「next」のいずれか
link_text — リンクに使用するテキスト
var — 検索クエリ変数の名前(デフォルトはswpquery
searchwp_search_results_paginate_links

検索結果のページネーションリンクを出力します
engine — Search engine name (Default is default)
var — The search query variable name (Default is swpquery)
In addition to the above, arguments from paginate_links are also supported.
searchwp_search_result_image

Outputs Featured Image for the current result
size — Image size (Default is thumb)
searchwp_search_result_permalink

Outputs permalink for the current result with the text of the result’s permalink
direct — Whether to link directly to Media files (Default is 'true')
searchwp_total_results

Outputs a total number of results for the current search
engine — Search engine name (Default is default)
var — The search query variable name (Default is swpquery)
text — The text to use alongside the number of results. Supports %total% and %query% placeholders for precise formatting.[searchwp_total_results text="Found %total% results for %query%"] converts to “Found 0 results for example search”.

Here is a sample of a comprehensive implementation of Shortcodes that searches a supplemental engine with a name of my_test_engine :

<h3>Search Form</h3>
[searchwp_search_form engine="my_test_engine" target="http://example.com/supplemental-search/" var="swpquery" button_text="Find Results"]
<div class="search-results-wrapper">
[searchwp_total_results text="Found %total% results for %query%" engine="my_test_engine" var="swpquery"]
[searchwp_search_results engine="my_test_engine" var="swpquery" posts_per_page=10]
<h2>[searchwp_search_result_link direct="true"]</h2>
[searchwp_search_result_excerpt]
[/searchwp_search_results]
</div>
<div class="no-search-results-found">
[searchwp_search_results_none]
No results found, please search again.
[/searchwp_search_results_none]
</div>
<div class="search-results-pagination">
[searchwp_search_results_pagination direction="prev" link_text="Previous" var="swpquery" engine="my_test_engine"]
[searchwp_search_results_pagination direction="next" link_text="Next" var="swpquery" engine="my_test_engine"]
</div>
view raw gistfile1.html hosted with ❤ by GitHub

You can customize the attributes as per the table above.

変更履歴

1.8.5

  • [Fix] Label FOR attribute not matching the input ID when a custom search variable is used.

1.8.4

  • [New] Added option to hide submit button.

1.8.3

  • [New] Compatibility with Live Ajax Search.
  • [Improvement] The searchwp_total_results shortcode supports text customizations.

1.8.2

  • [Fix] Prevent Error due to Shortcode recursion.
  • [更新] アップデーターを更新しました。

1.8.1

  • [Fix] posts_per_page attribute not reflected when using SearchWP 4.

1.8.0

  • [New] New Shortcode searchwp_search_results_paginate_links for paginated links.
  • [New] New Shortcode searchwp_search_result_image for result Featured Image output.
  • [New] New Shortcode searchwp_search_result_permalink for result permalink output.
  • [更新] アップデーターを更新しました。

1.7.0

  • [New] Compatibility with SearchWP 4.

1.6.1

  • [Fix] Issue with handling quotes.

1.6

  • [New] New Shortcode: searchwp_total_results to output the total number of search results.
  • [New] Adds placeholder argument to searchwp_search_form Shortcode.
  • [更新] アップデーターを更新しました。

1.5.4

  • [Fix] Additional checks to prevent edge case function redeclaration.
  • [更新] アップデーターを更新しました。

1.5.3

  • [New] New filter: searchwp_shortcodes_engine.
  • [New] New filter: searchwp_shortcodes_paginate_links.
  • [New] New filter: searchwp_shortcodes_pagination_prev.
  • [New] New filter: searchwp_shortcodes_pagination_next.
  • [更新] アップデーターを更新しました。

1.5.1

  • [新規] 新しいショートコード [searchwp_search_result_excerpt_global]
  • [新規] 新しいショートコード [searchwp_search_result_excerpt_document]
  • [改善] タームハイライトとの連携を強化するため、エスケープ処理を改善しました。

1.5

  • [改善] SearchWPライセンスキーに基づいた自動更新のサポート。

1.2.1

  • [新規] 出力中にいくつかの追加アクションを追加しました。

1.2

  • [変更] その他、ショートコード属性でGET変数を設定できるようにしました。

1.1

  • [修正] 属性がショートコードコールバックに渡されない問題を修正しました。

1.0

  • 初回リリース。

今日からより良いWordPress検索エクスペリエンスを作成しましょう

役に立たない検索結果で訪問者を失うことはもうありません。SearchWPを使用すると、独自のスマートなWordPress検索をすばやく簡単に作成できます。

Get SearchWP Now
複数の検索エンジンアイコン