WordPress search results include all posts and pages by default. However, you should exclude specific content, such as your store’s checkout page, premium online courses, or subscriber-only content.
This will save your searchers from scrolling through unnecessary or irrelevant results. This is crucial if you have an extensive blog post archive or an eCommerce store with many order-related pages.
Here, we discuss how to easily exclude specific pages, posts, authors, categories, and more from the WordPress search results.
Importance of Exclude Items From WordPress Search
The default WordPress search feature displays results from all WordPress posts and pages, which is suitable for many websites. However, there are times when you may need to exclude specific pages and posts.
For instance, if you have an online store, you should exclude the checkout and cart pages. Similarly, if you run a WordPress membership website or sell online courses, you’ll likely want to keep your premium, members-only content out of public search results.
You should also exclude other types of content, such as posts by specific authors. With that in mind, let’s explore how to exclude items from WordPress searches easily.
The SearchWP plugin is the most straightforward way to exclude pages, authors, categories, taxonomies, tags, and more. It’s incredibly user-friendly and empowers you to enhance the WordPress search feature to deliver more relevant results.
This plugin excludes entire content types from the search results, including specific pages, posts, and custom post types. To get started, simply install and activate the plugin.
For detailed instructions, let’s discuss how to install a SearchWP WordPress plugin:
Activate the SearchWP Plugin. Navigate to SearchWP >> Settings and press the ‘General’ tab.
Enter your license in the ‘License Key’ field located in your account on the SearchWP site. After that, click the ‘Verify Key’ button.
Make a Custom Search Algorithm
Once you activate the plugin, you can customize how SearchWP indexes, searches, and displays your content. It’s like creating a personalized Google search algorithm for your WordPress blog or website.
First, you’ll need to set up a site-wide search engine before you can exclude specific pages, posts, authors, and more from your custom search results page.
To begin, navigate to SearchWP >> Algorithm.
In the settings, you will find different content types that the SearchWP plugin searches by default, including pages, posts, and media files.
Each section has sliders for ‘Applicable Attribute Relevance‘, which control how SearchWP plugin ranks your site’s content.
For instance, if you move the ‘Title‘ slider to the left and the ‘Content‘ slider to the right, the content will be given more weight than the title.
You must exclude specific types of content from search results, such as pages, posts, and custom post types.
For instance, if your WordPress blog contains pages like a contact form or homepage, you should exclude all pages from the search results so that only blog posts appear.
To achieve this, press the ‘Sources & Settings‘ button.
Open the pop-up and uncheck the content, including all pages you want to exclude from the WordPress search. Once you’ve done that, press the ‘Done‘ button.
After customizing the default search engine settings, you must save your changes. Even if you plan to exclude specific pages, authors, or other content, you must first save your new sitewide search algorithm.
To do so, scroll to the top of the screen and press the “Save” button.
SearchWP will immediately begin rebuilding the index. Depending on your Internet connection speed and WordPress hosting provider, this process may take a few minutes.
Once you see ‘Index Status 100%‘, rest assured that SearchWP has successfully indexed all your content and settings.
The excluded content will no longer appear in the search results.
From WordPress search, exclude specific posts, pages, and custom post types
After creating a custom search algorithm, you can exclude specific posts, pages, or custom post types from your WordPress search results.
For instance, if you are using WooCommerce, you may want to exclude your store’s contact form, account login, and checkout pages to ensure that searches only return products. This can help you create a more effective WooCommerce product search and boost your sales.
To achieve this, you can use the ‘Exclude UI’ extension, which adds an ‘Exclude from search’ box to the page editor.
To get started, navigate to the WordPress dashboard, go to SearchWP >> Extensions, locate the ‘Exclude UI’ extension, and press the ‘Install’ button.
To exclude a post, page, or custom post type from appearing in WordPress search results, open the post and make sure the ‘Post‘ option is selected in the right-hand menu.
Then, tick the ‘Exclude from search‘ box.
After completing, press on ‘Update‘ to save your changes.
You can also exclude specific pages and custom post types using the process as mentioned earlier. The only difference is that the right-hand menu will display ‘Page‘ or the name of the custom post type instead of ‘Post.’
From WordPress Search Exclude Specific Categories, Tags, and Custom Taxonomies
This will open a pop-up where you can edit the search engine rules. Just press the ‘Add Rule‘ button to create your first rule.
Open the first dropdown menu and choose ‘Exclude entries if.’ Utilize the remaining settings to specify the content you want to exclude precisely.
For instance, if you want to exclude a specific category, simply type in the category name.
Additionally, input any custom taxonomies you wish to exclude.
To exclude specific post tags from the search results, you need to open the dropdown menu, choose ‘Tags,’ and then type in the name of the tag you want to exclude.
To add another rule, press the “Add Rule” button and repeat the same process described above. When you are satisfied with the rules, press the “Done.”
After customizing your rules, scroll to the top of the page and press the “Save” button to store your changes and rebuild the index.
When visitors search your WordPress website, SearchWP will definitively exclude all the selected categories, tags, or custom taxonomies from its results.
From WordPress Search Exclude Specific Author Posts From WordPress Search
You can add code to exclude posts created by a specific author on your website. An easier way for users to add and manage custom code snippets is to use WPCode, the most popular code snippet plugin used by over 1 million websites.
WPCode makes it easy to add code snippets without having to edit your functions.php file, and it allows you to update your WordPress theme without losing customizations.
To get started, you need to install and activate WPCode.
After activation, navigate to Code Snippets >> Add Snippet. Then, hover over ‘Add Your Custom Code’ and choose ‘Use snippet’ when it appears.
This will take you to the ‘Create Custom Snippet’ page, where you can type in a name for the code snippet. This is just for your reference, so you can use anything you want.
To proceed, open the ‘Code Type’ dropdown and select ‘PHP.’ Then, paste the following snippet into the code box:
To exclude a specific author from the search results, replace “24” with the user ID of the author you want to exclude.
Additionally, you can exclude multiple authors from the search results by adding their user IDs separated by a comma.
After the code box, you will find insertion options. The two main insertion options are ‘Auto Insert‘ and ‘Shortcode.’
Choosing the ‘Auto Insert‘ method is essential so that WPCode automatically inserts and executes the code across your entire site.
Remember to assign tags to your code snippets, which can help you organize them by topic and functionality.
Once you are satisfied with the snippet, scroll to the top of the screen and press ‘Save Snippet.’
To activate the code snippet on your site, toggle the ‘Active‘ switch. Then, press ‘Update‘ to save the change.
The author will now be excluded from the WordPress search results.
Conclusion
In conclusion, it is crucial to exclude specific posts, pages, or authors from WordPress search results to enhance the user experience on your site significantly. By implementing custom code or utilizing plugins, you can tailor the search functionality to meet your needs better, ensuring that users find the most relevant content.
This helps maintain the quality of search results and directs attention to the most important pages. As you refine your search parameters, you must regularly review and update your exclusions to adapt to your site’s evolving content, ultimately creating a more streamlined and effective browsing experience for your audience.
Leave a Reply