1

I'm attempting to output a list of entries using slug names. When I do the following, the entries are automatically reordered in alphabetical (title) order. Same thing happens if I target the ID's instead of the slugs.

{% set menu = craft.entries.slug(['home', 'about', 'services', 'news', 'contact']).order(null).find() %}
{% for entry in menu %}
  {{ entry.title }}
{% endfor %}

Is there a way to output the list the same way I put it in?

1 Answer 1

2

I think you can try .fixedOrder(), but you might have to query by ID and not slug.

.fixedOrder(true)
5
  • Thanks for the quick responce. Didn't seem to work. No errors; just returns an empty array. May 5, 2017 at 13:55
  • Did you try with the id's craft.entries.id([3, 2, 1]).fixedOrder(true) May 5, 2017 at 14:02
  • Using ID's doesn't do any reordering. Basically does nothing. I thought I'd try another variation of the same thing, but no joy there either: craft.entries({'id':[49, 40, 39, 5, 38]}).fixedOrder(true).find() May 5, 2017 at 14:09
  • IDK, I've used it in the past... maybe remove .find() May 5, 2017 at 14:14
  • Dammit... I wasn't seeing anything different because it was being cached! My mistake. You are right though, it works now :) Thank you! Interestingly, removing .find() still works too. May 5, 2017 at 14:20

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.