Have the List Widget display the most recently added events

Both the standard List Widget (in The Events Calendar) and its advanced cousin (in Events Calendar PRO) naturally list upcoming events in date order.

What if instead of using the start date of each event, though, we want to use the publication date - in other words, we want a way to show the world which events have been added most recently - regardless of when they are taking place?

It turns out we can add some code to change the way the List Widget works. The snippet is listed below. You can add this as a standalone plugin or even to your theme's functions.php file. With this in place, list widgets will show the most recently published events first.

Of course, you may not wish to make all list widgets behave that way and for that reason, you can add some constraints to help target specific widgets and sidebars.

For instance, if you have a widget entitled "Newly Added" you can opt to modify the behavior of that widget only by changing the following line (found at the bottom of the snippet):

new EventsListWidget_NewlyAddedEvents();


new EventsListWidget_NewlyAddedEvents( array(
    'widget_title' => 'Newly Added'
) );

Further detail on adding constraints is provided near the bottom of the snippet itself :-)