I have a views of unpublished contents of content-type X, which has the Term Y.

It works fine with published content but a thing that I noticed is that if I unpublished a content that has a taxonomy term, in Views it loses the term associated with it, therefore I cannot filter my list based on taxonomy term anymore.

I also found Taxonomy Entity Index module but it doesn't work at all.

Also a related issue on drupal.org

Is there any workaround for this?


For anyone who might encounter the same issue:

It looks like that it's a common issue in D7 and unfortunately going to be in D8, but hopefully the fix will be in core for D9.

Right now we have to use TEI module as a workaround for D7 and D8.

If you are installing this module into an existing site, visit admin/config/system/taxonomy-entity-index to rebuild the Taxonomy Entity Index.

Also note that in Views there will be some new fields/filters to work with, for instance instead of Content: Has taxonomy terms in filters section of views, you should use Taxonomy Entity Index: Has taxonomy terms on Nodes and for exposing the taxonomy terms also you should use Taxonomy Entity Index: Has taxonomy terms on Nodes not the default Content: Has taxonomy terms.

|improve this answer|||||
  • Sohail wrote "Right now we have to use TEI module as a workaround for D7 and D8." But here: TEI module; I see that there is only drupal 7 and not drupal 8. – Randy Skretka Sep 3 '16 at 2:12
  • For D8, the TEI module isn't ready to use in prod.But @SeanC tips work. – webmaster pf Nov 15 '19 at 10:36

"Lookup published nodes with this taxonomy term" is such a common use-case that the Taxonomy module keeps a taxonomy_index table in the database to optimize for it. This is what the Content: has taxonomy term ID views argument queries. Unfortunately, it is only for published content.

In Drupal 8, there is a workaround. Taxonomy term fields are just a special case of Entity Reference fields, which have their own views argument handler, and do not partake of this special index. So, if Content-type X has a 'Tags' field, you can build a view based around Content: Tags (field_tags), and that will include unpublished content as you'd expect.

|improve this answer|||||
  • This is what helped me - to filter by a field in my content type that uses taxonomy term as entity reference. Thanks! – ant Feb 7 '18 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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