Search code examples
sortingsql-order-byexpressionengine

How to prevent channel entries from sorting by edit_date when ordering/sorting by two custom fields?


I have a channel entries tag that I am trying to order by a custom date field that is used for the day, then I want to sort them by another custom field that is used for the start time.

The ordering and sorting works properly until an entry gets edited. The edit_date then takes precedence and the entry gets moved to the top.

Below is the basic Expression Engine markup I am using:

day-of-week = Expression Engine date field

start-time = Third-party installed field type from Devotee https://devot-ee.com/add-ons/time-select

{exp:channel:entries channel="{segment_1}" category="12" orderby="day-of-week|start-time" sort="asc|asc" sticky="no"}

<span>{day-of-week format="%D"}">{session_date format="%D. %M. %d, %Y"}</span>

<span>{start-time format="%g:%i %a"} - {end-time format="%g:%i %a"}</span>

Solution

  • I ended up breaking up my channel entries into three separate blocks that corresponded to each day of the week that I needed - Wednesday, Thursday, and Friday. That way I only had to order/sort by one parameter - the time.