New answers tagged


The equivalent SQL would be something like SELECT * FROM players ORDER BY teamName IS NOT NULL DESC, postDate DESC; but I'm not sure how that would translate in a simple element query. It'd be something like: {% set players = craft.entries.section('players').orderBy('teamName IS NOT NULL DESC, postDate desc').all() %}


I believe this won't work the way you want it with a single query, especially with reliable performance. The problem is that you actually want 2 different sort criteria being combined. I would recommend you add an additional field just for sorting using this plugin: It allows you to use TWIG to prepare a value ...

Top 50 recent answers are included