Stand with Ukraine. Fight for freedom and democracy

Donate
Back to contents

JetSearch: How to Exclude Certain Terms and Posts in AJAX Search Query

This tutorial provides a detailed guide about setting search excluding certain terms and posts using the JetSearch AJAX Search widget.

Tutorial requirements:

  • JetSearch — apply the fastest AJAX search and manage the way the results are displayed, using advanced stylization settings;
  • WordPress Gutenberg editor and free JetStyleManager — style any Gutenberg block & adjust its visual rendition;
  • Elementor free — add the necessary widget into the editor, style it up, and publish it right away.

Excluding Certain Terms and Posts in a Search Query in Elementor

1 Step — Open the page where you added the AJAX search widget with the Elementor editor.

page with ajax search

2 Step — Adjust the widget settings

Firstly, proceed to the Content tab and unfold the Search Query section.

ajax search query

Now you need to specify the source (the search areas) over which the search will be done.

To add a source, simply click on the Plus button and select the needed one from the drop-down list. You can select as many source areas as you want.

add a source to the search query

Below you will see two options: Include and Exclude. Click on the Exclude one and determine the certain terms and whether you need specific posts.

In our example, we have posts with different categories and tags. We want to exclude the posts in the Interview and Awards categories from the search.

bookstore posts

Under the Terms, start typing the needed categories or tags.

added terms

To exclude a specific post from the search, just start entering its title under the Posts.

exclude a specific post

3 Step — After that, save the settings and check the search on the front end.

The needed posts were successfully excluded from the search results.

search results on the front end

Excluding the Posts from the Search Results in Gutenberg

JetSearch works not only with the Elementor page builder. This plugin allows applying a Search block using Gutenberg as well.

Open the page in the default WordPress editor. Click on the “Add block” button and find the AJAX Search block.

ajax search block

Proceed to the Block tab and firstly unfold the Search Query section. Here you need the set the search area.

search query area

Scroll down and unfold the next section called Search Query Includes/Excludes.

search query settings

The process is similar to the one described in the first part of this tutorial for the Elementor editor.

Simply add the terms under Exclude and select a specific post if needed.

added terms to the exclude

Don’t forget to click the “Update” button and preview the search block on the front end.

Now you know how to exclude some terms and posts in a search query with the AJAX Search widget.