The Toolset View block lets you dynamically display lists of posts. You can add Query Filters to a View so that it only displays posts that meet specific criteria you choose.
- How to Add a Query Filter
- Filtering Options
- Available Query Filters
- Select the main View block
- In the right sidebar, expand the Content Selection menu
- Click Add a filter
You can filter by many different options. We will go through the most popular options on this page.
Each Query Filter offers different options for providing the value to filter by. The most common options are to filter by a specific value, URL parameter, or shortcode attribute.
- Filtering by a specific value means the View will always display or exclude what you tell it to.
- Filtering by URL parameter or shortcode attribute allows you to build a View once, then have it show different outputs based on how the URL or shortcode is configured.
As an example, we can look at the Post ID Query Filter.
By choosing specific post IDs, this View will always display or exclude the posts mentioned.
Select the Posts with those IDs option, and enter a single post ID, or a comma-separated list of post IDs, e.g. 302,12,309
When you link to the page that contains your View, you can specify the post IDs you want filtered in or out as URL parameters. This allows you to link to the same View throughout your site, but change what it displays based on the URL.
Select Posts with IDs set by this URL parameter, and enter the name of the URL parameter you want to use. The default is post_ids.
or for multiple post IDs
If you still use the legacy Views plugin or you want to keep your URL free of parameters, you can specify the post IDs you want filtered in or out as a shortcode attribute.
Select Posts with IDs set by the View shortcode attribute and enter the name of the attribute you want to use. The default is ids.
[wpv-view name="Filter by post id" ids="302,12,309"]
You can filter your View using any of the following Query Filters. You can also apply multiple filters to customize your output even more.
The Post ID filter for Views allows you to include or exclude posts based on their IDs.
Filtering by Post Status allows you to load only posts that match a certain status. This includes custom post statuses.
You can filter Views that display hierarchical post types by Post Parent.
WordPress has a built-in post hierarchy concept which allows you to set individual posts as parents of other posts of the same type. The native Pages post type is an example of this. When you register a new post type with Types, you can specify if the post type is hierarchical or not.
This should not be confused with Types post relationships which allow you to specify parent-child relationships between different post types.
The post_parent field is a standard WordPress field stored in the wp_posts table which contains the post ID of the parent post (zero if there is no parent).
When you add a Parent Post query filter it is this field that is being compared.
Standard WordPress posts can be marked as sticky, meaning they are shown before other posts on the posts archive (or a blog) page.
You can add a Query Filter to a View which makes the standard WordPress loop return only sticky posts, or all posts except sticky posts.
Views lets you filter by as many custom fields as you need.
Filtering views by taxonomy lets you load specific content arranged using tags, categories and custom taxonomy.
With a Post Author Query Filter, you can let users view:
- Only their posts
- Posts by a specific author
- Posts by authors set by URL parameter
- Posts by authors set by a Views shortcode attribute
You can add text search to a View using the Post search filter. This returns only posts where the specified string is found in the post title or the post body.
Views allows you to filter based on the date you published or modified a post. You can find detailed information about this filter on our page about filtering by date.
- Filtering Toolset Views by Dates
- Enabling Legacy Version of Toolset Views
- Styling Custom Searches
- Styling Views and Archives
- Adding Custom CSS to Templates, Archives and Views
- Show all related topics...
- Passing Arguments to Views
- Display Dynamic Sources Inside all Text Blocks
- Displaying Form Data
- Displaying a List of Posts on A Map
- Creating Sliders with Dynamic Post Content
- Adding Dynamic Content to Your Homepage
- Creating a View
- Creating Responsive Columns and Grids
- Display Content Conditionally
- Using Third-Party Hidden Fields