WordPressの検索結果からページを除外する方法を知りたいですか?
初期設定では、WordPressのビルトイン検索はすべての投稿とページを検索結果に含めます。訪問者が探しているものを見つけやすくするために、特定のコンテンツを除外して、検索結果に表示されないようにすることができます。
この投稿では、WordPressの検索結果から特定のページを除外する方法を順を追って説明します。
なぜWordPressの検索結果からページを除外するのか?
WordPressの初期設定では、検索結果にすべての投稿とページが含まれます。
しかし、これはすべてのサイトでうまく機能するとは限りません。例えば、オンラインストアを運営している場合、アカウントページ、購入手続きページ、サンキューページなどのページを非表示にしたいと思うかもしれません。
同様に、会員制サイトを運営している場合やオンラインコースを販売している場合は、購読者限定のコンテンツが一般の検索結果に表示されないようにしたい。
それでは、WordPressの検索結果からページを除外する方法をご紹介しましょう。このチュートリアルのナビゲーションには、以下のクイックリンクを使用できます:
注:このガイドでは、サイト訪問者がサイトの検索ボックスを使ってコンテンツに目を通す、サイト内検索に焦点を当てています。
Googleの検索結果からページを除外したい場合は、WordPressのページをGoogleから非表示にする方法をご覧ください。
ステップ1:WordPress検索プラグインのインストール
WordPressの検索結果からページを除外する最も簡単な方法は、SearchWPプラグインを使用することです。これは、30,000以上のサイトで使用されているWordPress用の最高の検索プラグインです。
SearchWPを使えば、コメント、カスタム投稿タイプ、PDFファイル、WooCommerce商品、カテゴリーなど、WordPressが初期設定で無視しているコンテンツを検索することができます。コンテンツを除外することもできます。
さらに詳しく知りたい方は、SearchWPのレビューをご覧ください。
最初に行う必要があるのは、プラグインのインストールと有効化です。詳しくは、WordPressプラグインのインストール方法のステップバイステップガイドをご覧ください。
有効化したら、SearchWP ” Settingsに行き、’General’タブをクリックする。
ここで、「ライセンスキー」ボックスにライセンスを入力する必要があります。この情報は、SearchWPサイトのあなたのアカウントの下にあります。入力が完了したら、’Verify Key’ボタンをクリックしてください。
ステップ2:カスタム検索アルゴリズムの作成
プラグインを有効化した後、SearchWPがどのようにインデックスを作成し、検索し、コンテンツを表示するかを微調整することができる。あなたのWordPressブログやサイトのためだけのカスタムGoogle検索アルゴリズムを作成するようにこれを考えることができます。
検索結果からページを除外する前に、サイト全体の検索エンジンを作成する必要があります。
ここでは、ページ、投稿、メディアファイルなど、SearchWPが初期設定で検索する異なるコンテンツタイプのセクションが表示されます。
各セクションには独自のアプリケーション属性関連性スライダーがあり、SearchWPがあなたのオンラインマーケット、ブログ、サイトのコンテンツをどのようにランク付けするかをコントロールすることができる。
例えば、「タイトル」スライダーを左に、「コンテンツ」スライダーを右に動かすと、コンテンツがタイトルよりも重くなります。
検索結果からすべてのページを除外することも、特定のページだけを除外することもできる。
WordPressサイトの検索結果にすべてのページが表示されないようにするには、「ページ」の隣にある小さなゴミ箱アイコンをクリックします。
ページ」のチェックを外すポップアップが開きます。
その後、「完了」をクリックするだけで、検索バーと検索結果からすべてのページが除外される。
初期検索エンジン設定のカスタマイザーが終わったら、変更を保存しましょう。特定のページを除外する場合でも、最初にサイト全体の新しい検索アルゴリズムを保存する必要があります。
これを行うには、画面を一番上までスクロールし、「保存」ボタンをクリックします。
SearchWPはインデックスを自動的に再構築します。インターネット接続の速度とWordPressホスティングサービスによっては、数分かかる場合があります。
Index Status 100%’ と表示されれば、SearchWPがすべてのコンテンツと設定をインデックスしたことがわかります。
サイトが自動的にWordPressの検索 機能を使用するようになります。
ステップ3:WordPressの検索結果から特定のページを除外する(オプション)
WooCommerceの購入手続きページなど、特定のページを検索結果から除外したいですか?
上記のプロセスに従ってサイト全体の検索アルゴリズムを作成した後、検索結果から個々のページを除外することができます。
これを行うには、Exclude UIエクステンションを使用します。このエクステンションは、ページエディターに「検索から除外する」ボックスを追加します。
WordPressダッシュボードで、SearchWP“ Extensionsに向かいます。ここでExclude UI拡張機能を見つけ、その「インストール」ボタンをクリックします。
その後、検索結果から除外したいページを開きます。右側のメニューで「ページ」タブが選択されていることを確認します。
これで、「検索から除外する」ボックスにチェックを入れることができる。
その後、「更新」ボタンをクリックするだけで、このページは検索結果に表示されなくなります。さらに多くのページを検索結果から非表示にしたい場合は、上記のプロセスを実行するだけです。
ステップ 4: 検索フォームを作成して埋め込む
さて、ページを除外するカスタム・ワードプレス検索エンジンを作成したので、そのエンジンを使って検索フォームを作る必要がある。
すべてSearchWP” Search Formsに行き、’新規追加’ボタンをクリックするだけです。これでカスタマイズ可能な新しい検索フォームが作成されます。
ステップバイステップの手順については、カスタム WordPress 検索フォームの作成方法をご覧ください。このガイドでは、検索フォームを作成し、ページ、投稿日、ウィジェット対応エリアに埋め込む手順を説明します。
検索バーに検索フォームを追加することもできます。クラシックテーマを使用している場合は、SearchWP モーダル検索フォームプラグインを使用する必要があります。
ブロックテーマを使用している場合は、ナビゲーションメニューにSearchWPフォームを追加するためにフルサイトエディターを使用することができます。
より詳しい情報は、WordPressメニューに検索バーを追加する方法をご覧ください。
ボーナスのヒントWordPressの検索結果から投稿、タクソノミーなどを除外する
WordPressの検索結果をさらに微調整して、特定のコンテンツのみを検索結果に含めたい場合があります。プライベート投稿、ユーザーに検索してほしくないカスタム投稿タイプ、タグのような特定のタクソノミーなどの項目を除外するのに便利です。
例えば、タグを検索結果から除外することは、社内で整理するためにタグを使用しているが、ユーザーを混乱させたくない場合に有効かもしれない。
このような場合は、WordPressの検索から特定のページや投稿者などを除外する方法をご覧ください。
もう一つの設定は、検索結果から特定のページカテゴリーを除外することです。これを行うには、ページを分類するための明確なシステムが必要で、少し計画が必要かもしれません。ただし、追加のエクステンションをインストールする必要はありません。
特定のカテゴリーのページのみを表示するには、WordPressでカテゴリー別に検索する方法をご覧ください。
WordPressの検索結果からページを除外する方法について、この投稿がお役に立てば幸いです。また、サイト用の無料SSL証明書を取得する方法についての初心者向けガイドや、中小企業に最適なビジネス電話サービスもご覧ください。
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.
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!
Gabriel says
Thanks a lot! Seems to work perfectly.
WPBeginner Support says
Glad our guide was helpful
管理者
joel araujo says
just what I needed, at the right time
thanks
WPBeginner Support says
Glad our guide could help
管理者
Ivan says
Thanks. This worked for me. I wanted to exclude gallery appears in search results and this code does exactly what I need. Thanks
Pete says
This is really basic. It would be nice to see how to exclude only particular page templates, or blog categories.
VishvjeetCheema says
You are true life savers. always.
Gautam Nagraj says
Hello team WPBeginner
I am facing a new problem
when I have tested crawled pages on Google by writing
site:example.com
Then it showing pages & posts properly but also showing pagination links
example.com/page/2/
Like this
So how can I avoid this?
Please help me.
Joni says
Thanks! :)!
Laura Rafferty says
Wondering if there’s a way to target different search forms with this technique. I’d like the main website search form to target pages only; and the blog search form to target posts only.
Val says
I have some pages that are password protected (via main WP option to password protect a page) but they are still showing up in WP search with the excerpts. My understanding is that by default, the excerpts should not appear, you should see “There is no excerpt because this is a protected post.” I can use the Simply Exclude plugin but I’m wondering why the excerpts are showing up in the first place and I’d rather not add another plugin if I don’t have to.
deny jackrose says
Thank you very much sir.. this post really help me.. you rock man .. !!
Victor says
Thank you very much. You guys did the trick. I was looking for this and couldn’t find it anywhere else.
Nice job, guys.
Noah says
When someone just hits SEARCH with the criteria being ‘blank’, ALL pages show up in the results. How can I have NO results show in this situation?
Jornes says
Noah, if you are saying about search result, you can validate the search form using javascript. So that people are forced to key in the words before do the searches.
Samsir Alam says
Thanks bro.
WPBeginner Staff says
Glad to hear. You are welcome.
Dimitra says
Thank you so much for the article and some comments with codes that helped me a lot!
Bijay Pakhrin says
Worked perfectly, Thanks alot
redimin says
Work Fine !
Bruno says
Thanks bro! Your code helped me a lot.
Henry says
This worked much better than passing a hidden field (which is what I’ve been doing).
Laura says
This worked great, thanks! How can I include WordPress Native BBPress forum topics in the search results?
Thanks,
L
WPBeginner Support says
You can try bbpress search plugin.
管理者
Jornes says
Hi! I would like to ask how do i exclude the specified pages i wanted to excluded from searches? And how do i know what is the ID of the page? Can someone tell a solution? I wanted to excluded some pages which are useless to visitors.
Thank you!
hamza says
works for me. thank you!
Spyridon says
You are a real life saver. I tried codes from WordPress forum but didn’t work out. Yours is working for me!
luckyankit says
Well just wanted to say thank you for this… wonderful article
gormanIT says
Can you alter this function to exclude specific pages/posts from search? Ive been searching for this functionality and havent found anything.
David Allred says
Perfect! I was expecting it to be a bit more complex than that. Thanks a ton!
Michael Bailey says
Thank you so much. This was super helpful, fixing my problem with the speed of a cut and a paste (and a test)..
Success in all your ways!
Michael.
Katie says
Well, that’s almost perfect. I searched and found that many site’s offering us to hardcode the category ids to search id but this is cool. One question, i have to do the pagination myself so when i add this filter i won’t get offset issues .. right?
Editorial Staff says
No, you should not have offset issues.
管理者
Mohsen says
Hi
may I put your tutorials in my blog with a link to wpbeginner.com? my blog is in Farsi and I think many persian users need these tips.
thanks a lot
Editorial Staff says
No you may not translate any of our tutorials entirely. You may write a summary and then link to our site.
管理者
Rilwis says
This hack excludes not only pages from search results, but also other custom post types. So if we have many custom post types in our WP site, we can put them in the statement like this:
$query->set(‘post_type’, array(‘post’, ‘custom-post-type’));
Rein says
Thanks Rilwis, just what i needed!