<p>You're wanting to show a paginated list of related entries from a single entry page based on a tag relationship, correct?</p>

<p>This should point you in the right direction:</p>

<pre><code>{% set segment = craft.request.lastSegment %}

{% for entry in craft.entries.slug(segment) %}

    {% set tagId = entry.myTagFieldHandle.first() %}

    {% set relatedEntries = craft.entries.relatedTo(tagId).id('not ' ~ entry.id) %}

    {% paginate relatedEntries as related %}

        {% for entry in related %}

            {{ entry.title }}

        {% endfor %}

    {% endpaginate %}

{% endfor %}
</code></pre>

CC BY-SA 3.0
2014-07-18T20:32:50.367Z
That did the trick! Now off to learn what ('not ' ~ entry.id) is all about...
Steph
CC BY-SA 3.0
2014-07-18T20:37:43.070Z
The tilde in Twig converts all operands into strings and concatenates them thus excluding said entry id from the relationship. http://twig.sensiolabs.org/doc/templates.html#other-operators
Ryan Shrum
CC BY-SA 3.0
2014-07-18T20:43:31.817Z
Thanks for the explanation Ryan, I definitely have a lot to learn both regarding Craft and Twig. Every comment and solution is a huge help.
Steph
CC BY-SA 3.0
2014-07-18T20:05:30.737Z
2014-07-18T20:15:28.570Z
2014-07-18T20:15:28.570Z
Ryan Shrum
<p>I'm trying to show related entries to current entry by tag ID (which is working fine) but getting hung up when trying to exclude the current entry from the loop. I think I'm having an issue with paginate tags requiring an element criteria model but I'm not able to figure out how to get around this. </p>

<pre class="lang-twig prettyprint-override"><code>{% set segment = craft.request.lastSegment %}
{% for entries in craft.entries.slug(segment) %}
  {% set current = craft.entries.slug(segment) %}
  {% set tagId = entry.myTagFieldHandle.first() %}
  {% set suite = craft.entries.relatedTo(tagId) %}

    {% paginate suite|without(current) as entries %}
      {% for entry in entries %}
        {{ entry.title }}
      {% endfor %}
    {% endpaginate %}

{% endfor %}
</code></pre>

<p>Excluding the without filter on paginate outputs everything fine, but includes the current entry. I know there are probably better ways of doing this and I appreciate any help, thanks!</p>

<filter>
Show related entries without current entry
# Show related entries without current entry

(Asked by: username_0 on 2014-07-18)

I'm trying to show related entries to current entry by tag ID (which is working fine) but getting hung up when trying to exclude the current entry from the loop. I think I'm having an issue with paginate tags requiring an element criteria model but I'm not able to figure out how to get around this. 
{% set segment = craft.request.lastSegment %}
{% for entries in craft.entries.slug(segment) %}
  {% set current = craft.entries.slug(segment) %}
  {% set tagId = entry.myTagFieldHandle.first() %}
  {% set suite = craft.entries.relatedTo(tagId) %}

    {% paginate suite|without(current) as entries %}
      {% for entry in entries %}
        {{ entry.title }}
      {% endfor %}
    {% endpaginate %}

{% endfor %}

Excluding the without filter on paginate outputs everything fine, but includes the current entry. I know there are probably better ways of doing this and I appreciate any help, thanks!

**Tags:** filter


---

## 1 answers

### Answer by username_1 on 2014-07-18. Score: 17 | Accepted answer

You're wanting to show a paginated list of related entries from a single entry page based on a tag relationship, correct?
This should point you in the right direction:
{% set segment = craft.request.lastSegment %}

{% for entry in craft.entries.slug(segment) %}

    {% set tagId = entry.myTagFieldHandle.first() %}

    {% set relatedEntries = craft.entries.relatedTo(tagId).id('not ' ~ entry.id) %}

    {% paginate relatedEntries as related %}

        {% for entry in related %}

            {{ entry.title }}

        {% endfor %}

    {% endpaginate %}

{% endfor %}

> **Comments:**
> **username_0**: That did the trick! Now off to learn what ('not ' ~ entry.id) is all about...  
> **username_1**: The tilde in Twig converts all operands into strings and concatenates them thus excluding said entry id from the relationship. http://twig.sensiolabs.org/doc/templates.html#other-operators  
> **username_0**: Thanks for the explanation Ryan, I definitely have a lot to learn both regarding Craft and Twig. Every comment and solution is a huge help.  

---

