I'm looking for a way to query all categories that have at least one relation. I'm not looking for the relatedTo() parameter, which would give me categories related to something specific.

Basically, if we talk in Wordpress terms, I'm looking for hideEmpty = true.

Is there anything like that in Craft?

Something like: craft.categories.group('products').hasRelated()

1 Answer 1


Add this to your chain...


It's not very well documented, but you can see it described in this old SE thread. In the docs, it's mentioned very briefly here.

  • Hi Lindsey, Thanks for your answer. Unfortunately, that would give me all entries that have a Category associated to it. I want it the other way around. I need all Categories that were assigned at least once somewhere. Oct 23, 2018 at 17:26

Your Answer

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

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