<p>You'd need to get the tag model first.</p>

<pre class="lang-twig prettyprint-override"><code>{% set tag = craft.tags.search('My Tag').first() %}
{% if tag %}
    {% set entries = craft.entries.relatedTo(tag) %}
{% endif %}
</code></pre>

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

CC BY-SA 3.0
2016-03-10T00:48:07.030Z
2018-01-15T13:51:15.027Z
2018-01-15T13:51:15.027Z
carlcs
<p>I want to only show entries that match a specific tag. I'm trying to do something like:</p>

<pre><code>{% paginate craft.entries.section('blog').relatedTo('tagName').order('score') as entriesOnPage %}
</code></pre>

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

<templating><entries><tags>
Query Entries by Tag
# Query Entries by Tag

(Asked by: username_0 on 2016-03-10)

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?

**Tags:** templating, entries, tags

---

## 1 answers

### Answer by username_1 on 2016-03-10. Score: 5 | Accepted answer

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.


---

