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

1 Answer 1

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

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.