Do you want to add a taxonomies filter to your WordPress search?
Allowing users to search based on categories, tags, custom fields, and post types offers a great user experience. However, the default WordPress search is not very good or advanced enough to offer this feature.
In this article, we will show you how to add an Ajax powered taxonomies filter in WordPress search.
Why Use Ajax Taxonomies Filter in WordPress Search?
Ajax-powered search is faster and provides a better user experience than the default WordPress search function.
For example, a car dealership website may have custom taxonomies for different vehicle types, price ranges, models, and more. Ajax filters can help users find exactly what they need.
You can add similar search filters in WordPress and improve the user experience of your site. It also helps website administrators to organize their content, so that it could be easily found by users.
However, the default WordPress search is not that powerful and doesn’t offer filter content based on categories, tags, post types, product details, and more. If you use custom taxonomies on your site, the default search performs even worse.
This is where you’ll need a WordPress plugin to help you out. Let’s see how to add an Ajax taxonomies filter to WordPress search.
We’ll cover 2 methods in this article. The first method will help you show filters on the front end of your WordPress website. The second method will help you improve the default WordPress search and include taxonomies when searching posts and pages on your site.
Simply click the links below to jump ahead to your preferred section:
Method 1: Add Ajax Taxonomies to WordPress Search using SearchWP
You can add Ajax taxonomies to WordPress search by using SearchWP. It is the best search plugin for WordPress and makes it easy for users to find what they’re looking for on your website.
It goes beyond using just the content on your blog posts and pages to look up things. SearchWP uses custom fields, taxonomies, WooCommerce product attributes, text files, custom tables, and more.
Do note that SearchWP won’t show the taxonomies filters on the frontend of your website. However, it will include them in the search process and improve the default WordPress search.
First, you’ll need to visit the SearchWP website and sign up for an account. After that, you can download and install the plugin on your site. If you need help, then please see our guide on how to install a WordPress plugin.
Upon activation, you will need to go to SearchWP » Settings from the WordPress admin panel. From here, simply enter the license key, which you can easily find in your account area.
After that, you can go to SearchWP » Algorithm page from the WordPress dashboard.
Here, you can edit the search relevance for your website. For instance, you can increase weights for title, content, slug, and excerpt to help users find what they’re looking for.
To add taxonomies to the search relevance, you can click the ‘Add/Remove Attributes’ button.
Next, a new popup window will open.
You can click the Taxonomies dropdown menu and select whether you’d like to include categories, tags, formats, or all of them in the WordPress search.
After selecting the taxonomies, don’t forget to click the ‘Done’ button.
You should now see the taxonomies for your WordPress blog post search algorithm. You can use the slider to increase their relevance in WordPress searches.
You can also click the ‘Edit Rule’ button to determine what content can and cannot show up in the search results.
For instance, SearchWP will include all the categories on your website. You can remove categories from which you don’t want the content to show up or add multiple conditions to customize the search results.
Don’t forget to click the ‘Done’ button when finished.
You can now edit the search algorithm for your pages, media files, WooCommerce products, and more to show up in SearchWP.
Now, whenever a visitor searches for pages and posts on your website, SearchWP will include taxonomies during the search process.
You can use a free WordPress plugin like Search & Filter to add an Ajax taxonomies filter to your website. It is very easy to use and allows your users to search based on category, tag, custom taxonomy, post type, and more.
First, you will need to install and activate the Search & Filter WordPress plugin. For more details, please see our guide on how to install a WordPress plugin.
Upon activation, you can add a shortcode to show the Ajax taxonomies filter anywhere on your website.
For instance, you can enter the following shortcode to show the category and post-type dropdown filter:
In the screenshot above, you can see the taxonomies filter as checkboxes. Users can simply select categories from which they want to view posts and pages.
Do you want to learn how WordPress search works, and how you can make it better?
By understanding and improving the built-in WordPress search, you can help visitors find what they’re looking for. This can get you more conversions while keeping people on your site for longer.
In this article, we’ll look at how the default WordPress search works, and share tips on how to make it better.
How Does WordPress Search Work?
WordPress comes with a search system that will look for content within your website.
How the search bar looks and where it appears will vary depending on your WordPress theme, but most themes show the search bar in the top right corner.
Note: If your theme doesn’t show the WordPress search bar by default, then skip ahead to our FAQs, where we’ll show you how to add it.
Visitors can type a search query into this field, and WordPress will search:
As you can see, it doesn’t search widgets, user comments, categories, tags, WooCommerce products, or PDF documents. It also doesn’t search image gallery titles, captions, or alt text, although you can search this content using a search engine plugin like SearchWP.
WordPress performs this search using the WP_Query class. It will start by displaying any posts that have the search term in the post title, arranged in reverse-chronological order, meaning that the newest entries will be displayed at the top of the results.
After that, it’ll show any posts that have the matching term in the post content.
For example, imagine you’ve just published a post about cats titled ‘My Favorite Pet’, and you also have an older post titled ‘Best Cat Photos.’ In this case, searching for ‘Cat’ will display the older ‘Best Cat Photos’ post first, since it has the search term in the title.
This may not a problem for WordPress blogs or websites that only have small amounts of content. However, this ordering logic will often show inaccurate or confusing results for bigger blogs, online stores, or business websites.
The built-in system is also missing some of the features that people expect from modern search engines. This includes autocomplete, live Ajax search, filtering, and spellcheck.
Why Improve the Default WordPress Search?
An advanced, fast, and accurate on-site search can help visitors find interesting and relevant content, which will keep them on your website for longer. This can increase pageviews and reduce bounce rate in WordPress.
Since visitors are spending more time on your site, this will send positive signals to the search engines. This can improve your WordPress SEO, which means search engines like Google will show your content to more people and drive more visitors to your website.
People who are using your site’s internal search are already highly engaged. They’re actively looking for specific content, which may mean they’re ready to take actions such as buying a product, signing up to your WordPress membership site, or booking an appointment.
If these people can’t find what they’re looking for, they may give up and go to a different website. This means you’re losing out on visitors who were ready to convert.
A search results page is also an example of personalized content since you’re showing the visitor results that match their unique search query. By providing personalized content that’s accurate and helpful, you can improve the visitor experience. Once again, this can encourage them to convert.
Performance is another reason why it’s a good idea to replace the default WordPress search with a better alternative.
The larger your WordPress website gets, the longer it’ll take WP_Query to scan your database and get the results. This means your site’s search will get slower, as your website gets bigger.
How to Make the WordPress Native Search Better
On-site search helps visitors find what they’re looking for, including products to buy and interesting blogs to read. Since it’s such an important part of your site, it’s a bad idea to rely on the limited built-in WordPress search.
With that being said, let’s see how you can improve the native WordPress search.
Show Instant Results With Live Ajax Search
Live Ajax search adds a dropdown and autocomplete feature that’s common in search engines like Google.
As the user types, live search guesses what they want to search for and then shows them results without even reloading the page.
This can help visitors find the right content, without having to manually press the ‘Search’ button or wait for the page to reload.
The first thing you need to do is install and activate the plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.
Upon activation, the default WordPress search form will automatically use the Ajax live search feature. If you visit your site and start typing into the search bar, then you’ll see the instant search in action.
Change the Default Search URL Slug
By default, WordPress search URLs typically look something like this:
http://example.com/?s=search-term
The extra ?s= characters make this URL more difficult to read and understand, which can confuse visitors who are trying to find their way around your site.
Even worse, these URLs aren’t optimized for search engines which can stop them from correctly indexing your site’s contents.
You can go ahead and use the following custom code to replace the ‘/?s=search-term’ characters with ‘search.’ Your slug will look something like this when finished: http://example.com/search/wordpress
To use something other than ‘search’ in your URL, simply customize the code snippet below.
By uploading PDFs to your WordPress website, you can share information about your services and products in a format that works on all devices. They’re also perfect for offering your visitors ebooks, user manuals, menus, and more.
However, WordPress only searches the contents of its database by default, so it will only look at the title and description of your PDF files, and not their contents. As a result, your visitors may struggle to find the best PDF for their search query.
The good news is that you can use a custom search plugin to improve the default WordPress search experience. If your PDFs are unencrypted, then the right search plugin will index the contents and metadata of your PDFs and add them to the search results.
If you have multiple categories of content on your website, then you might want to let users restrict their search to a specific category. This can help visitors find the right content, faster.
For example, if you have an online store then it often makes sense to let customers search within a particular product category.
If you run a membership site, then you might use search by category to help visitors find other members, groups, forums, online courses, and other specific kinds of content. For more information, please see our guide on how to add search by category in WordPress.
Make a Smart WooCommerce Product Search
WooCommerce has its own built-in search, but it doesn’t look for matches in product attributes, reviews, or product descriptions. This omission can stop shoppers from finding products they want to buy on your online store, so you get fewer sales.
To get even more sales, you may want to fine-tune the kind of products WooCommerce includes in its search results. For example, you might only show products that are on sale or come with free shipping.
Custom post types allow you to go beyond posts and pages and create different content types for your website. Custom post types can have different custom fields and their own custom category structure.
For example, if you run a movie review website, then you would probably want to create a ‘movie reviews’ post type that has fields for the director, release date, and more.
At WPBeginner, we use custom post types for our Glossary section to keep it separate from our blog posts.
If you use custom post types, then you may want to create a form that allows visitors to search only that content.
For example, we also have a form that only searches WPBeginner’s coupon codes.
By default, the built-in WordPress search will include all posts and pages in its search results.
However, you may want to exclude certain pages and posts from the search results. For example, if you’re running a WordPress membership website or selling online courses, then you’ll typically want to exclude your premium content from public search results.
If you’re running an online store, then you may want to hide content like your account page, checkout page, and thank you page. To help you out, we’ve created a guide on how to exclude pages from the WordPress search results.
In this guide, we’ve explored how the default WordPress search works and shared lots of tips on how to improve it.
However, you may still have some questions about this important feature. That said, here are some of the most frequently asked questions about WordPress search.
How Do I Improve WordPress Search?
The best way to improve the built-in WordPress search is by using SearchWP.
SearchWP is the best custom search plugin for WordPress and allows visitors to search any content on your site including documents, WooCommerce products, custom fields, tags, comments, and more.
It also lets you customize the WordPress search algorithm, so you can control exactly where the content appears in the search results.
Since the main navigation menu typically appears across your entire site, visitors will be able to search for pages, posts, products, and more, from any page of your website.
If you’re using a block-based theme such as ThemeIsle’s Hestia Pro or Twenty Twenty-Three, then you can add a search bar to your theme using the full-site editor (FSE).
To do this, go to Appearance »Editor in the WordPress dashboard.
By default, the editor will show your theme’s home template. If you want to add the search bar to a different template, then click on the small arrow icon in the toolbar.
Then, select ‘Browse all templates.’
You’ll now see all the templates that make up your WordPress theme. Simply find the template where you want to add the search bar, and then click on its title.
You will now see this template in the full-site editor.
To go ahead and add a search bar, click on the blue ‘+’ icon.
In the popup that appears, type in ‘Search’ to find the right block.
You can then drag the block to the location where you want to show the search bar.
To customize the block title or placeholder text, simply type it into the search block where it says ‘search’ or ‘optional placeholder.’
When you’re happy with how the block looks, click on ‘Save’ to make the search bar live.
How Do I Add Search to a WordPress Page or Post?
You can add a search bar to a specific page or post using the built-in Search block.
This is a good choice if you want to control exactly where the search bar appears on every page and post, or you only need to offer search on specific areas of your website.
To get started, simply open the page where you want to add a search form and then click on the + icon.
In the popup that appears, type ‘Search’ to find the right block. Once you click on the Search block, it will add the block to your page.
By default, the block uses ‘Search’ for both its label and the button text.
This will be visible to visitors, so you may want to replace it with something more descriptive by typing into the text fields.
You can also add some placeholder text to the search bar. This text will disappear automatically when the visitor starts typing.
To add a placeholder, simply click on ‘Optional placeholder…’ and then start typing.
When you’re happy with how the Search block looks, you can go ahead and either publish or update the post.