Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!

share|improve this question
up vote 9 down vote accepted

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 ' ~ %}

    {% paginate relatedEntries as related %}

        {% for entry in related %}

            {{ entry.title }}

        {% endfor %}

    {% endpaginate %}

{% endfor %}
share|improve this answer
That did the trick! Now off to learn what ('not ' ~ is all about... – Steve Jul 18 '14 at 20:32
The tilde in Twig converts all operands into strings and concatenates them thus excluding said entry id from the relationship. – Ryan Shrum Jul 18 '14 at 20:37
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. – Steve Jul 18 '14 at 20:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.