I want to return entries in the news section, except the one that has a slug the matches url segment 2.

I've tried:

{% for entry in craft.entries.section('news').slug(not craft.request.getSegment(2)).limit(6) %}...
{% for entry in craft.entries.section('news').slug('and, not craft.request.getSegment(2)').limit(6) %}...

But neither work - all entries are returned.

What's the right syntax please?


I think there is just some confusion between what should be a string or not. From the docs on Parameter Value Syntax:

To exclude entries with a given value, you must pass in a string, prefixed with not

To that end the following should work for your example:

{% for entry in craft.entries.section('news').slug('not ' ~ craft.request.getSegment(2)).limit(6) %}...
  • Glad I could help :) Oct 9 '14 at 13:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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