<p>Marion's answer is fine but you can also do it a different way, and move the conditional logic out of the for loop. By adding it to the query, you can ask for a specific amount of items to grab, and it won't mess up the loop.index values if you need them.</p>

<p>This is how I would do it.</p>

<pre><code>{% set relatedEntries = craft.entries.relatedTo(tag).id('not ' ~ currentEntry.id).limit(4).find() %}

{% if relatedEntries | length %}
    {% for e in relatedEntries %}
        {# entry stuff here #}
    {% endfor %}
{% endif %}
</code></pre>

CC BY-SA 3.0
2015-03-16T16:58:35.040Z
This is easier to understand, thanks Sean!
joshmedeski
CC BY-SA 3.0
2015-03-14T19:36:45.653Z
2015-03-14T19:36:45.653Z
Seán O'Grady
<p>When you have your tag[s], fetch the related entries like this:</p>

<pre><code>{% set relatedEntries = craft.entries
  .relatedTo({
    targetElement: tag,
    field: 'tags'
  })
%}
</code></pre>

<p>This is assuming the field for the tag is <code>tags</code>, and the tag[s] you want to match is <code>tag</code>.</p>

<p>Then you can loop through the related entries. If you want to exclude the current entry, your loop might look like this:</p>

<pre><code>{% for e in relatedEntries if e.id != currentEntry.id %}
  do things with {{e}}
{% endfor %}
</code></pre>

CC BY-SA 3.0
2015-03-13T20:45:04.820Z
2015-03-13T20:45:04.820Z
Marion Newlevant
<p>I'm trying to show related entries for a single item.</p>

<p>I want to look up a specific tag(s), and search for any entries that share the same tag(s) then display those related items.</p>

<p>I've read through the documentation and searched around but couldn't find a solution.</p>

<entries><search><tags>
Find Related Entries with Identical Tags
# Find Related Entries with Identical Tags

(Asked by: username_0 on 2015-03-13)

I'm trying to show related entries for a single item.

I want to look up a specific tag(s), and search for any entries that share the same tag(s) then display those related items.

I've read through the documentation and searched around but couldn't find a solution.

**Tags:** entries, search, tags

---

## 2 answers

### Answer by username_1 on 2015-03-14. Score: 2 | Accepted answer

Marion's answer is fine but you can also do it a different way, and move the conditional logic out of the for loop. By adding it to the query, you can ask for a specific amount of items to grab, and it won't mess up the loop.index values if you need them.
This is how I would do it.
{% set relatedEntries = craft.entries.relatedTo(tag).id('not ' ~ currentEntry.id).limit(4).find() %}

{% if relatedEntries | length %}
    {% for e in relatedEntries %}
        {# entry stuff here #}
    {% endfor %}
{% endif %}

> **Comments:**
> **username_0**: This is easier to understand, thanks Sean!  

---

### Answer by username_2 on 2015-03-13. Score: 1

When you have your tag[s], fetch the related entries like this:
{% set relatedEntries = craft.entries
  .relatedTo({
    targetElement: tag,
    field: 'tags'
  })
%}

This is assuming the field for the tag is tags, and the tag[s] you want to match is tag.
Then you can loop through the related entries. If you want to exclude the current entry, your loop might look like this:
{% for e in relatedEntries if e.id != currentEntry.id %}
  do things with {{e}}
{% endfor %}


---

