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.
Before you start check tutorial requirements:
Elementor (Free version) or Block editor (Gutenberg);
JetSearch plugin installed and activated.
Excluding Certain Terms and Posts in a Search Query in Elementor
Open the page where you added the AJAX search widget with the Elementor editor.
Adjust the widget settings.
Firstly, proceed to the Content tab and unfold the Search Query section.
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.
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.
Under the Terms, start typing the needed categories or tags.
To exclude a specific post from the search, just start entering its title under the Posts.
After that, save the settings and check the search on the front end.
The needed posts were successfully excluded from the search results.
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.
Proceed to the Block tab and firstly unfold the Search Query section. Here you need the set the search area.
Scroll down and unfold the next section called Search Query Includes/Excludes.
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.
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.