1

If I have a huge list of TV shows and Movies, many of them have "The" in the title, meaning they all get grouped together if you order by title.

Is it possible to "filter out" a word in entry titles when using orderBy?

{% set entries = craft.entries().section('media').orderby('title asc').limit(24).all() %}
2
3

{% set entries = craft.entries().section('media').orderBy("(CASE WHEN `title` LIKE 'The %' THEN SUBSTRING(`title`, 5) WHEN `title` LIKE 'A %' THEN SUBSTRING(`title`, 3) ELSE `title` END) asc").limit(24).all() %} worked.

1
  • Really cleaver! – piotrpog Jul 15 '20 at 13:57

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.