How to Use Term Name Instead of Term ID in Views Filter?

| | 1 min read

When using a taxonomy term reference field in the filter criteria of a Drupal View, the configuration will store the term ID instead of the term name. This can lead to issues in different environments (development, testing, staging, production) where the term IDs may vary. If you deploy the configuration via code, this could break the functionality, as the views will refer to term IDs that might not exist or differ in the production environment.

The solution is simple: add a relationship to the taxonomy term reference field within the view. This action will make the term name available for you to use in the filter criteria. Doing so ensures that the view filters consistently based on term names, regardless of the environment.

Steps to implement Term name instead of Term ID in Views Filter

1. Add a relationship to the taxonomy term reference field.

Add views relationship

2. Add new filter criteria for Taxonomy term: Name.

Add Filter Criteria

3. Configure the filter to set the relationship we added earlier and the term name you want to filter.

Configure Views Filter criteria