I have several nodes and several taxonomies, but only some nodes have taxonomy relationships.

enter image description here

My problem is that the taxonomy filter shows those terms too which don't have any node relationships at all, example:

enter image description here

So even if I don't have any nodes in "Category 1", the term will show up in the filter.

Is there a way to remove those taxonomy terms from the filter which have no content associated to them?

  • One way is to use a Contextual filter with Summary option instead of the Exposed filter. It looks a bit different but acts the same. It gives you links of existing taxonomy terms (there's an option to include only the ones existing in the results) that you click through to see the results. Search for it to see examples and how to set it up.
    – prkos
    Commented Nov 13, 2020 at 16:10

2 Answers 2


Managed to solve this with the combination of the Search API and Facets modules. Actually, it's not that complicated when you know what to do.

  1. Created a search index with the content of the categories.
  2. Created a new view with a Filter criteria with Content datasource (Content type).
  3. Finally, added a new facet where the source is the view display page I have created, and the field is the category.

In Views, there is an option to specify a relationship and to require that relationship. You can find it in your View's config page, under Advanced. Just add a relationship to your taxonomy vocabulary and check the option to require the relationship.

The screen shot below is from the Content view that ships with Drupal 8, which is a great example of how to define a required relationship. enter image description here

  • This will not work. This will hide nodes without a category, but it will not change the available categories in an exposed filter.
    – Hudri
    Commented Apr 11, 2022 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.