Create Filters

Learn what filters are in a view and how to manage them.

Transcript

Trainer (00:00):
Filters play an important part in a view. Once you’ve selected what content you want to query and the fields you want displayed, the next thing you need to configure is how you want to filter that content. Filters allow you to, as the name suggests, filter the queried content. You could, for example, only want to display published or unpublished content. Another example is you only want to display a specific content type such as articles, but not basic pages. For all of these examples, you can simply add a filter to a view. We briefly covered filters when we created this view. And currently, this view will only display published articles. If we scroll down to the filter criteria section, here we can see the published filter. We can change the operator from “is equal to” to “is not equal to” and we can change the status from “yes” to “no.”

Trainer (01:01):
So if you want to display all unpublished articles, all you need to do is select “is equal to” under operator and make sure “no” is selected from published status. Let’s click on cancel because we don’t want to make this change. And then below the published filter, we have content type. This has been configured to only display article content types. We can change the operator from “is one of” to “is not one of,” but if we select “is one of,” then it’ll display any content type which has been selected under content types. In this example, it’ll only display article content types because article has been checked. But if we select “is not one of” as the operator, then it’ll display all other content types except article. So if you want to display all content types except one, then select “is not one of” as the operator and choose the content types you want to exclude.

Trainer (02:05):
Now, another thing to be aware of is that the filtering options do vary depending on the field type. In this filter, the operator is called “is one of” and “is not one of,” but if we cancel this and go to published, the operator in this filter is called “is equal to” and “is not equal to.” So, just remember the options will vary depending on the field type. Let’s jump out of this popup and to add a filter is pretty straightforward. Just click on the add button in the filter criteria section and if we search for authored by and select it, because this is an entity reference field, we can filter content by a specific user. So if you just want to display content from a specific user, then look at using the authored by filter. Now, we don’t want this filter. So, click on remove.

Scroll to Top