How to Add an Ajax Powered Taxonomies Filter in WordPress Search
We all know that the default WordPress search is not perfect. However, if you could allow your audience to filter results based on categories and tags, custom taxonomies, or post types, this will help them find posts more easily. In this article, we will show you how to add an Ajax powered taxonomies filter in WordPress search.
Why use Ajax Powered Search in WordPress?
Ajax powered search is user-friendly, faster and provides a better user interface. For example, a laundry web site may have custom taxonomies for different service types, price ranges, detergents, etc. This interface can help users find exactly what they need. It also helps website administrators to organize their content, so that it could be easily found by users.
The first thing you need to do is install and activate Ajax WP Query Search Filter plugin. Upon activation, it will add a new menu item “Ajax WPQSF” in your WordPress admin sidebar. Clicking on it will take you to the plugin page where you can click on the Add New Search Form button to build your search form.
First, you need to provide a title for your form this will be used to recognize your form internally, as you can create multiple search forms with this plugin. After that you can choose post types this search form will look into. You will see the default WordPress posts and pages along with any custom post type you may have on your site.
The other option is choosing a taxonomy. You can choose the Boolean relationship between taxonomy queries. For example, if a user selects books and Music, would you want the plugin to match both terms or display the result if either one of them is found. The next option is to add a taxonomy, to do that you need to click on the Add Taxonomy button.
A new popup would appear and you will see category and any other custom taxonomy you may have on your site. You can add a label for the taxonomy. You can choose to hide empty terms. Lastly, choose a display type for your taxonomy terms. You can display them in checkboxes, drop-down menu, or radio buttons. After selecting custom taxonomy, you can further fine tune your search form by adding custom meta fields just like you added taxonomy.
The next tab is for result settings and other options. On this tab, you can add a traditional keyword search box and here is the catch. If a user selects a taxonomy or custom meta field and enters the keyword, then the plugin will run a search query for the keyword and will ignore taxonomy and custom meta field selection by the user.
You are done! Now just save your search form, and you will see a shortcode. You can add this shortcode in any post, page, or text widget on your site to display the search form.
Using this advanced filter search and sorting feature can help you create simple but very efficient sort and search filters on your WordPress site.
Latest posts by sarah ali (see all)
- How to Get Started with A/B Testing for WordPress - June 23, 2017
- Top 5 CDN Providers for WordPress: 2017 - June 22, 2017
- How to Create an Admin User in WordPress Database via MySQL. - June 20, 2017