22

How can I exclude the current entry when I've structured my syntax like this?

{% set entries = craft.entries({
  section:        'blog',
  order:          'postDate',
  limit:          5,
}) %}

1 Answer 1

39
{% set entries = craft.entries({
  section:        'blog',
  order:          'postDate',
  limit:          5,
  id:             'not ' ~ entry.id
}) %}

or

{% set entries = craft.entries({
  section:        'blog',
  order:          'postDate',
  limit:          5,
}).id('not ' ~ entry.id) %}
3
  • Thanks for the reply. I tried that but then I get the error: "Variable "entry" does not exist". Commented Jul 19, 2014 at 18:50
  • 1
    What is the current entry that you are trying to exclude? Commented Jul 19, 2014 at 18:52
  • Ah, I understand. I'm editing the wrong template :( Commented Jul 19, 2014 at 18:54

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.