CMS ordering

I think I sent this as a DM to Steve W rather than posting, apologies for that.

Steve W posted a video about this a while ago but the video is no longer available.

My CMS list refers to upcoming events.

Sort order in CMS is driving me nuts! If I set the date field type as text and formatted as “2026-09-28” all my posts appear but not in date order. If I change the date field type to date then again they all show but again not in date order. If I then click on the date field of a post and use the date picker i am confronted with and set it to the actual (future) date then the post vanishes!

My posts relate to upcoming events. So as a final check I then with the date field set to type date and using the item date field and then set the date to before today it reappears.

So in conclusion If i set the date field to text it all works but does not sort correctly, If i set to type date if it is a future date it will not display it!

Any suggestion would be welcome, thanks

Addendum:

I even tried putting all the items in date order with retrospective dates. It still ignores the date order which seems to me to be random. I can find no explanation of the order they appear in. Not alphabetical or date.

Yes :+1: I posted about this but I was misunderstood…

Because I bulk edit the markdown files in a desktop folder - it processes them at different times..

When I load them back into elements - they are scrambled and there is no order.

Because this works and is sorted by the system in the webpage - I’ve just learned to deal with the inserted mess :slight_smile:

Perhaps :thinking: I am not understanding your problem…

But I think I am….

I think you do understand my problem, thanks!

It seems crazy to me you cannot have a bunch of items in a ‘post list’ and not be able to sort by date!

I agree that “ordering” in the CMS is something Realmac needs to spend more time on.

However, I’ll point out that there are two views about how that should work. One is that an .MD file should have a central, fixed-at-creation, date (and other fields). The other is that you can change-at-will date (and all fields) and order them in any way you’d like.

Sorting has always been a real pain (both to programmers and users). But perhaps there’s a need for Realmac to actually ask us as to how we want to sort CMS things.

I agree and understand, I just want to sort, I don’t care which method they adopt personally just so long as something works!

So after consulting Claude it suggested prefixing the title with a date something like 2026-11-06.

This works and posts are listed correctly in date order. I appreciate that is how the ‘add new file’ auto creates the filename but I had no idea that we could not junk that date front end to make the filename simpler. Anyhow you may not (probably not) enter the items in the order they should be displayed.

Mine are numbered and it doesn’t order them…

You have to order them with a date in US format 2026-09-28-myfile.md

p.s. this can be any date from 2000-01-01 to 2099-12-31, just so long as the dates define the order.

Yes might rename them…. For my 365 song a day project it’s currently 001 - 365

Tedious I agree! Good luck

Thanks for the report. We’re looking into it.

The odd order is a bug. When date_published isn’t filled in we weren’t falling back to date, so the list came out in no useful order. That’s being fixed, and you’ll be able to choose Date under Order By.

Future dates disappearing is the Date filter on the Collection. It defaults to In the past, which suits blogs. For upcoming events, set it to All dates or In the future.

I’ll update this thread when the sort fix is out.

I think the most likely issue is that you are trying to sort by “Date Published” but using a date field in your markdown.

If you sort by “Date Published” you currently need a date_published field for this to work correctly. As I said above, we’ll fix this in the next Elements release so it works more intuitively :slight_smile:

Thanks @ben but can I point out that even if I add this field and set the order by date_published unless I set the filename with the date prefix it still doesn’t work. I set the date_published field to date format, should the date be entered with quotes around it? e.g. 2026-09-29 or “2026-09-29”

Thanks

I haven’t had any problems with date sorting in my projects.

Maybe you could post an example of your frontmatter so we can take a look at it.

Here is a typical front matter:


title: xyz
date_published: ‘2026-08-03’
date: ‘2026-08-03’
author: A N Other
image:
src: workshop/hall-exterior.png
alt: xyz headshot
workshop_date: 12 Dec 2026

Try it like this:

date_published: “2026-09-27”
date_modified: “2026-09-27”

So, use double quotes around the dates.

As a general recommendation, I would always put all values in double quotes.

Thank you I will try it tomorrow.

I tried but it didn’t work for me sadly.

@ben, thanks for working on this but it still does not work for me and I do not understand why unless I prefix the file name with the date.

Attached is a screenshot from Elements and a screenshot from the admin, this screenshot is the 1st published item but occurs 3rd on the webpage Workshop Diary

I will revert the site soon to the date prefixed file names to keep the site correct, but if you see this post before then you will see what I mean.

The front matter for this file is:

title: Pushing Hands
date_published: “2026-06-01”
date_modified: “2026-06-01”
date: “2026-06-01”
author: Nicci van Dyk
image:
src: workshop/tai-chi-qigong-pushing-hands.png
alt: AllofUs headshot
workshop_date: 03 Oct 2026

The Workshop Date as the last field is a text field that I use to overcome sorting issues, you can ignore it.

Thanks for the front matter and screenshots, and for leaving the non-prefixed filenames up for a bit.

We’ve run your setup through a local test with the same sorting filters your site uses. With Order By set to Date Published, the list comes out in date order either way, and Ascending / Descending are both working here.

Your live workshop diary still looks newest-first, which feels like to me that the page on the server might not have been the latest code.

Could you try one more pass when you have a moment?

  1. On the Collection, ensure the “Order By” is set to Date Published and the direction you want (Ascending or Descending)
  2. Re-publish all files
  3. Open the published workshop-diary/index.php on the server and find the following two lines of code and paste them in a reply:
$orderBy = "...";
$orderDirection = "...";

Those two lines will tell us exactly what got set on the server. Date prefixes are fine to keep as a stopgap until then.