Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPBカップ
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

WordPressでカテゴリー別に検索する方法(ベストメソッド)

編集メモ: WPBeginner のパートナーリンクから手数料を得ています。手数料は編集者の意見や評価に影響を与えません。編集プロセスについて詳しく知る。

WordPressでカテゴリー別検索を有効化したいですか?

サイトにカテゴリー別検索を追加すれば、公開するコンテンツにかかわらず、訪問者が探しているものを見つけやすくなります。例えば、訪問者は特定のブログカテゴリー、製品カテゴリー、会員レベルなどを検索するかもしれません。

このガイドでは、WordPressにカテゴリー別検索機能を追加する方法をご紹介します。

How to search by category in WordPress (2 ways)

なぜWordPressにカテゴリー別検索を追加するのか?

カテゴリーは、WordPressサイトのコンテンツを整理する簡単な方法です。カテゴリーは、訪問者が興味深い投稿を見つけるのにも役立ちます。

例えば、多くのサイトではカテゴリーをドロップダウンメニューやサイドバーに表示している。

A list of post categories on the WPBeginner website

ブログ投稿が多い場合は、さらに一歩進んで、サイトにカテゴリー別検索機能を追加することができます。これにより、ブログ投稿がたくさんある場合でも、訪問者が探しているコンテンツを見つけやすくなります。

WooCommerceを使用している場合は、オンラインストアの商品カテゴリー検索を作成し、より多くの売上を得ることもできます。

Product categories on an eCommerce site

同様に、WordPressの会員制サイトを運営している場合、カテゴリー別検索を利用することで、訪問者が特定のメンバー、グループ、フォーラム、オンラインコースなどを見つけやすくなります。

それでは、WordPressにカテゴリー別検索機能を追加する方法を見ていきましょう。このチュートリアルでは、以下のクイックリンクを使ってナビゲーションすることができます:

ステップ1:SearchWPのインストールとセットアップ

WordPressにカテゴリー別の検索を追加する最も簡単な方法は、SearchWPを使用することです。これは最高の検索プラグインであり、WordPressのビルトイン検索を改善することができます。

SearchWPを使えば、カスタム投稿タイプ、PDFファイル、WooCommerce商品、カテゴリーなど、WordPressが初期設定で無視しているコンテンツを検索することができます。

さらに詳しく知りたい方は、SearchWPのレビューをご覧ください。

まず、SearchWPプラグインをインストールして有効化する必要があります。詳しくは、WordPressプラグインのインストール方法のステップバイステップガイドをご覧ください。

有効化したら、SearchWP ” Settingsに行き、’General’タブをクリックする。

Activating the SearchWP WordPress plugin

ここで、「ライセンスキー」ボックスにライセンスを入力する必要があります。この情報は、SearchWPサイトのあなたのアカウントの下にあります。入力が完了したら、’Verify Key’ボタンをクリックしてください。

ステップ2:WordPressの検索アルゴリズムをカスタマイズする

プラグインを有効化した後、SearchWPがどのようにインデックスを作成し、検索し、コンテンツを表示するかを微調整することができる。あなたのWordPressブログやサイトのためだけのカスタムGoogle検索アルゴリズムを作成するようにこれを考えることができます。

まずは、SearchWP Algorithmをご覧ください。

Creating a search by category feature for WordPress

ここでは、ページ、投稿、メディアファイルなど、SearchWPが初期設定で検索する異なるコンテンツタイプのセクションが表示されます。

各セクションには独自のアプリケーション属性関連性スライダーがあり、SearchWPがあなたのオンラインマーケット、ブログ、サイトのコンテンツをどのようにランク付けするかをコントロールすることができる。

例えば、「タイトル」スライダーを左に、「コンテンツ」スライダーを右に動かすと、コンテンツがタイトルよりも重くなります。

Changing the attribute relevancy settings in WordPress

WordPress検索から特定のページや投稿者などを除外することもできます。

また、「ソースと設定」ボタンをクリックすることで、より多くのコンテンツを検索結果に含めることもできる。

Configuring your website's search algorithm using SearchWP

異なるコンテンツタイプの横にあるボックスにチェックを入れることができます。例えば、ブログのコメントを検索可能にしたり、WordPressでPDFのインデックスと検索を追加したりすることができます。

変更が完了したら、「完了」ボタンをクリックします。

Making comments, PDFs, media, and more searchable on a WordPress website

これにより、新しいコンテンツタイプごとに新しいセクションが追加されます。異なるスライダーを使用して属性の関連性を変更できるようになりました。

検索の設定に満足したら、画面を一番上までスクロールし、「保存」ボタンをクリックします。

Saving your SearchWP search engine settings

SearchWPはインデックスを自動的に再構築します。インターネット接続の速度とWordPressホスティングサービスによっては、数分かかる場合があります。

Index Status 100%’ と表示されれば、SearchWPがすべてのコンテンツと設定をインデックスしたことがわかります。

Rebuilding the search index on your WordPress website

ステップ3:カテゴリー別検索フォームの作成

この段階で、カテゴリー別検索フォームを作成する準備ができました。これで訪問者が検索したいカテゴリーを選択できるようになります。詳しい説明が必要な場合は、WordPressでカスタム検索フォームを作成する方法の投稿をご覧ください。

まず、SearchWP Search Formsにアクセスしてください。そして、「新規追加」をクリックします。

Adding a custom search form to your WordPress website

次に、新しい検索フォームに名前を付けて、後で識別できるようにします。これは、一つのサイトに複数の検索フォームを作成する場合に便利です。

次に、検索フォームのレイアウトテーマを選択します。カテゴリーベースの検索フォームを作成するので、「カテゴリー検索」を選択します。

Creating a search by category form with SearchWP

下にスクロールすると、「カテゴリー検索」オプションが有効化されていることがわかります。また、クイック検索(検索キーワードの推奨を表示)と詳細検索(ユーザーが高度なフィルターを使って検索できる)を有効化することもできます。

Engineは、ステップ2で編集した「Default」を選択すればよい。

結果ページについては、WordPressの初期設定の検索結果ページを選択するか、SearchWPを使用して新規作成することができます。2番目の設定に興味がある場合は、WordPressで検索結果ページをカスタマイズする方法についてのガイドをお読みください。

Configuring the search form settings in SearchWP

次に、’Type of Search’(検索の種類)で、ユーザーが検索エンジンを使用する際に検索できるコンテンツの種類を選択することができます。このカテゴリー別検索フォームでブログ投稿の結果のみを表示させたい場合は、「投稿」を追加します。

しかし、ページやメディアファイルを含めたいなら、先に進んで『ページ』と『メディア』を入力する。

カテゴリーを選択」フィールドでは、検索フォームのドロップダウンメニューに任意のブログ投稿カテゴリーを含めることも除外することもできます。

その下で、フィールドラベルのプレースホルダーテキストを変更し、必要に応じて検索ボタンを有効化または無効化することができます。

Customizing the search by category form settings in SearchWP

下の方では、検索フォームの枠線、枠線の色、フォント、ボタンの形、ラベル、背景色、フォントを変更することができます。

あなたのWordPressテーマに合ったデザインに自由に変更してください。

Customizing the SearchWP form's style

検索フォームの設定に満足したら、ページを上にスクロールしてください。

そして、『保存』をクリックする。

Saving the SearchWP form

ステップ 4: WordPressにカテゴリー別検索フォームを埋め込む

カテゴリー別検索フォームを作成したので、WordPressサイトに埋め込んでみましょう。SearchWP は、Gutenberg エディター、フルサイトエディター、ブロックベースのウィジェットエディターを使って追加できる、使いやすい検索フォームブロックを提供しています。

WordPressページにフォームを追加してみましょう。新規または既存のページのブロックエディターを開き、「+ブロックを追加」ボタンをクリックします。

次に、’Search Form’ ブロックを選択します(’Search’ ブロックと混同しないでください。)

Adding the SearchWP search form block in WordPress

サイドバーの「ブロック」タブで、ドロップダウンメニューから作成したフォームを選択します。新規: カテゴリー別検索フォームが表示されます。

簡単な説明や画像など、ページに追加したい要素を自由に追加してください。そして、「公開する」または「更新する」ボタンをクリックしてください。

Selecting a SearchWP form in the block editor

WordPressのページをプレビューして、フロントエンドでフォームがどのように見えるか確認してください。

カテゴリー別検索フォームはこんな感じです:

Example of a search by category form made with SearchWP

WordPressのカスタム検索エンジンの作成についてさらに詳しく知りたい方は、以下のガイドをご覧ください:

この投稿がWordPressにカテゴリー別検索を追加するのにお役に立てば幸いです。WordPressのSEOツールやプラグインブログのトラフィックを増やす方法についてもご紹介しています。

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

情報開示 私たちのコンテンツは読者支援型です。これは、あなたが私たちのリンクの一部をクリックした場合、私たちはコミッションを得ることができることを意味します。 WPBeginnerの資金源 をご覧ください。3$編集プロセスをご覧ください。

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

究極のWordPressツールキット

ツールキットへの無料アクセス - すべてのプロフェッショナルが持つべきWordPress関連製品とリソースのコレクション!

Reader Interactions

21件のコメント返信を残す

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Mrteesurez says

    Can this guide be followed to create a search for a support site where each category will includes all support posts for a particular services or branch and other for theirs ??
    Thanks for this post.

  3. Hansan says

    Hey help , I want to create a search box for web page and it should search in only one page category. How can i do that in wordpress.

  4. Eric Thomas says

    This is exactly what I was looking for! Needed a sidebar for a separate review section, with a search bar that only searched that separate section. So this was perfect

  5. philips says

    Thanks for the support for this awesome plugin. i have tried the plugin, the search by name works fine but the category search is not showing any result. i guess it is not compatible with 3.5 — >3.8.
    i have tried changing “cat” to “category” but all to no avail . Any quick help will be hugely appreciated. Thanks in advance.

  6. Eric says

    After I installed this plugin, the original categories widget doesn’t work any more!
    Once I removed the plugin, it’s work again!
    I still can’t find the reason.

    Could someone tell me how to fix the problem?

    Thanks a lot!

  7. sergio says

    i run both regular search with google custom search, and the search category plugin, . i modified the searchform.php in order to have google search results ( with this shortcode ).
    When i use the search by category plugin the results are the same of the standard so they are not filtered obviously because i use in both case google custom search .
    so i would reset thestandard only for () for this plugin
    how can i Do?
    thanks

  8. Srinivas says

    Team,

    I tried the steps above, but when i added [sbc] in the text area, it just displayed that as a text instead of calling the search box. Am i missing something here.

    Else, also not sure where i can add the mentioned code in the theme template. Could someone help me with the specific theme file i need to edit.

    Thanks

  9. Gretchen Louise says

    Oh I’m so glad to find this plugin! I think I need to keep looking though because I need to have it search specific pages on my site as well as some categories of posts.

  10. Gitte Hansen says

    Search by category is only tested for WordPress version up to 3.4.2 – is it ok to install anyway? I use 3.5.0
    I really look forward to a functionality which will make it easier for my readers to browse and seach in my categories.
    Greetings Gitte

  11. Corrinda says

    I just did a review of different options for a client site and eventually installed the Search Everything plugin. It gives you the option to also configure what gets searched. And in this case I wanted to exclude a couple of categories.

  12. Azim says

    If no serious customization is needed, you could just use the following snippet in your searchform.php

    <form method="get" id="searchform" action="<?php echo home_url(); ?>">
    <input type="search" id="s" name="s" />
    <?php wp_dropdown_categories( 'show_option_all=All Categories' ); ?>
    </form>

  13. Alan says

    I use Relevanssi on one of my sites and it is great but I would love to add something like this to narrow search fields but rather than narrow by category. I’d like to narrow by custom taxonomy.

返信を残す

コメントありがとうございます。すべてのコメントは私たちのコメントポリシーに従ってモデレートされ、あなたのメールアドレスが公開されることはありませんのでご留意ください。名前欄にキーワードを使用しないでください。個人的で有意義な会話をしましょう。