Why Let Users Filter Posts and Pages in WordPress?
By default, WordPress comes with categories and tags for your users to easily find it.
However, users can only view one category, tag, or archive page at a time and it will only show one post type.
What if you wanted users to be able to filter content in more than one category or tag?
This kind of filtering can be particularly helpful when you have a lot of content, and you want users to filter it according to their own preferences.
Allowing Users to Easily Filter Posts and Pages
The first thing you need to do is install and activate the Search & Filter plugin.
Upon activation, the plugin will add a new menu item labeled Search & Filter to your WordPress admin bar.
Search & Filter plugin comes with a shortcode which accepts different parameters to display the filtering options. You can use this shortcode in a post, page, or inside a text widget.
1. [searchandfilter fields=”search,category,post_tag”]
You can also use the shortcode as a template tag in your WordPress theme files like this:
This will display the filtering options with search, category, and tags fields.
By default, the plugin accepts search, taxonomy, post_type, and post_date as fields.
Let’s take a look at another example. This time we will include category, tags, post types, and date fields.
You will need to use the shortcode like this:
Now instead of using a drop down a select field, you can also use checkboxes and add labels for each field.
If you use a separate page to display your blog posts, then you can add this shortcode to the page.
1. [searchandfilter headings=”Select categories:” types=”checkbox” fields=”category”]
If you are using multiple fields, types, and headings.
http://dreamsspark.com/wp-content/uploads/2017/05/FilterPost.jpg515890Poojahttp://dreamsspark.com/wp-content/uploads/2017/03/LOGO1.pngPooja2017-05-27 03:40:052017-05-29 04:05:05How Use Filter Posts and Pages in WordPress