You can use the relatedTo param on craft.tags
like you can with any Element inside Craft.
All Elements inside Craft can be related to one another. There is a .relatedTo
parameter available on all of the query elements like craft.entries
and craft.tags
.
You will need to pass a category object into this relatedTo parameter. I have included the group param below but this can be omitted if you want to query all of your tags.
{% set tags = craft.tags.group( 'groupName' ).relatedTo( category ) %}
More info on using Relations in Craft: https://craftcms.com/docs/relations
UPDATE
The relatedTo
param takes one of the following:
- An AssetFileModel, CategoryModel, EntryModel, UserModel, or TagModel
object
- An element’s ID
- An array of element objects and/or IDs
To get a CategoryModel using a slug inside your template you can use:
{% set category = craft.categories.slug( 'theslug' ).first() %}
This will set category
to a CategoryModel which you can then use inside the .relatedTo
param in the above example.
UPDATE 2
If you've set category to have their own URL's then category
inside the template you've set to use is a CategoryModel.
You then set entries
to all entries related to the category. Finally, use these entries to get all related tags.
{% set entries = craft.entries.relatedTo( category ).find() %}
{% set tags = craft.tags.relatedTo( entries ).find() %}