3

I want to only show entries that match a specific tag. I'm trying to do something like:

{% paginate craft.entries.section('blog').relatedTo('tagName').order('score') as entriesOnPage %}

This doesn't seem to net any results though. Is .relatedTo() not the way to go when limiting results to a specific tag?

1 Answer 1

5

You'd need to get the tag model first.

{% set tag = craft.tags.search('My Tag').first() %}
{% if tag %}
    {% set entries = craft.entries.relatedTo(tag) %}
{% endif %}

Replace search with whatever other information you have from the tag, to get more precise results, e.g., slug, id properties.

0

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.