How to Let Users Filter Your WordPress Posts and Pages
The more your users like your website, the more often they will return to it. Sounds like a no-brainer, doesn’t it? The trick is giving your users the features they expect from your website; sometimes even the features they don’t know they need beforehand. User experience is key, in other words. Now, no matter what kind of website you may be running, it will have content on it. If it has been up for a long time, it will likely have a lot of content. However, each individual visitor has their own tastes and needs. If you let users filter your posts and pages, they will have an easier time finding the content they want, and their impressions of your website will be all the better for it.
Setting up a search bar, or even using WordPress’s default search function will go some way towards facilitating your visitors’ search for desired content (and we recommend you do so), but searches have a crucial limitation: they will only return results containing keywords your visitor uses when submitting a query. Filtering your posts and pages will, conversely, lead your visitors to more related content.
In this article, we will show you how to let your users filter your posts and pages in WordPress. But first, let us take a few moments to tell you about why we think you should do it.
Why Should I Let Users Filter My Posts And Pages?
The answer is obvious: to improve your website’s UX. But how does letting your users filter your content improve UX?
However your visitors stumble upon your website, the way you keep them interested is having the content they want. But great content, unfortunately, isn’t enough. Your visitors have to have an easy time finding what they want on your website. You could (and should) provide them with a search bar, but, as we have said earlier, a search will only render results based on keywords. With a filtering system, you provide your visitors with more. You give them results based on categories and tags – content they might not have explicitly searched for, but which is relevant to their interests. By catering to your visitors’ interests instead of just answering their queries, you not only give your visitors what they want, but also point them towards more of your content which they may find interesting, entertaining, or relevant.
Your visitors can typically click a category or tab, for instance, and view all the posts with the said tag or category. But sorting can actually be much more powerful than that. Your visitors might want to filter using more than one category or tag (say, posts from the Sports category with the Transfers tag) or maybe look up posts by a particular author tagged with a particular keyword – everything by said author on a certain topic.
This is particularly useful if your website hosts a lot of content, as it allows your visitors to get a bespoke experience. This is especially relevant if your content is broad and diverse, as would be the case for a news website, for instance. Visitors with niche interests will find their way to the content they want simply by using categories and tabs as filters. Everybody appreciates ease of navigation, even if they are not aware of it. And a good user experience means a better likelihood of their coming back for more.
How to Let Users Filter Your Posts And Pages Using a Plugin
The plugin we will be using is Search & Filter.
After having installed and activated the plugin, click on Settings on the Installed Plugins screen.
You will be taken to a screen detailing the ways to use this very versatile plugin. For starters, there is the default shortcode.
To see it in action, we will add it to a page. To do this in the Gutenberg editor, we will simply click the plus sign and add a shortcode block. Elementor users should, conversely, use the shortcode element from the left-hand side menu, while Classic editor users can simply paste the shortcode where they want it.
Since we are using Gutenberg, we need to paste the shortcode [searchandfilter fields=”search,category,post_tag”] from the plugin’s settings page to the shortcode block.
And now we have a fully functional search field with category and tag filters.
But can you customize this plugin to allow for more filtering options? Of course you can! It just takes a bit of fiddling with the shortcode itself.
Note how the shortcode [searchandfilter fields=”search,category,post_tag”] contains three criteria for sorting: the search field, the category, and the tag. You can completely eliminate the search field simply by erasing it from the shortcode.
[searchandfilter fields=”category,post_tag”] will render a filtering tool based solely on categories and tags.
If you want to allow your users to filter your content using more than one category or tag, you can do that, too. Simply alter the shortcode to [searchandfilter fields=”post_tag,post_tag”] and you will get a refined tag filtering tool.
So, with one simple, easy to use plugin, you can set up as many filtering layers as possible, making it really easy for your visitors to get exactly the content they are after: make your filters as loose or as refined as you like.
These filters can be especially useful if you know how to use WordPress taxonomies correctly. In fact, the better you organize your content, the better the filters will work. We also have a guide for you if you want to know more about best practices in organizing your WordPress content, but the gist of it is that you ought to keep categories broad, and really refine the tags.
Your posts should ideally belong to no more than one category, and have as many tags as you see fit. This is also how you should configure your content filter widgets: a category or two, and multiple tags. Be careful not to overwhelm your visitors with a multitude of options, though: if you feel your content is difficult to find, you can actually make the situation worse by overcorrecting this.
As we have shown, it’s not too difficult to let your users filter your posts and pages – you can do it with a reasonably simple and free plugin. It takes some time setting up and configuring the shortcode, but it’s well worth the improvement in user experience, especially if you are hosting a lot of diverse content. Good organization in terms of categories and tags is half the work, so be careful about that. Your visitors’ filtered searches will be really meaningful only if your content organization (i. e. your use of WordPress taxonomies) makes sense.