Open TomDeSmet opened 1 year ago
Hi, thanks for reaching out. I’m having trouble replicating this one. I get the same ordering in twig and via the elements api. Are you still experiencing this issue?
Hi there. Yes this is still an issue. We're working on other projects for now, so maybe keep this open en if we come across this again I can hopefully provide you with more leads?
Description
I'm using Element API to load entries and my criteria includes an
orderBy
clause that references custom fields (a date fielddateFrom
and a lightswitchavailability
). The criteria is:When I execute the same query in Twig I get totally differently sorted results:
{% set initialItems = craft.entries.section("events").dateTo(["or", ">=2022-08-02", ":empty:"]).orderBy("dateFrom ASC,availability ASC") %}
The results from twig are correct (they are the same as when I sort by
dateFrom
in the index in the CP). The results from Element API don't match. When I use a default field such aspostDate
ortitle
both return the correct results.Additional info