How to Filter Posts and Pages in WordPress

Please log in or register to like posts.

If you are looking to filter posts and pages on your WordPress site? In this article, we will show you how to filter posts and pages in WordPress.
First, you need to install and active the Search & Filter plugin. For more details, see our step by step guide on how to install a WordPress plugin.
after activation, the plugin will add a new menu item labeled Search & Filter to your WordPress admin top bar.


Search & Filter plugin comes with a shortcode which Shows different parameters to display the filtering options. You can use the shortcode in a post, page, or inside a text widget.

[searchandfilter fields="search,category,post_tag"]

You can also use the shortcode as a template tag in your WordPress theme files like this:

<?php echo do_shortcode('[searchandfilter fields="search,category,post_tag"]'); ?>
By default, the plugin accepts search, taxonomy, post_type, and post_date as fields.
This time we will include category, tags, post types, and date fields.

Now if you want to use drop down the select field, you can also use checkboxes and add labels for each field. To do that, you will need to add two more parameters to the shortcode.
If you use a separate page to display your blog posts, then you can add this shortcode to the page.
[searchandfilter headings="Select categories:" types="checkbox" fields="category"]

If you want to  using multiple fields, types, and headings, then you need to make sure that items are in the same order for each parameter.

[searchandfilter headings="Post type, Category, Tag" types="checkbox, select, select" fields="post_types,category,post_tag"]

Reactions

0
0
0
0
0
0
Already reacted for this post.

Reactions

Leave a Reply

Your email address will not be published. Required fields are marked *