The WordPress plugin The Events Calendar is a great way to add calendar functionality to your website. It is a free plugin available on the WordPress plugin repository and in my experience is the ONLY calendar option you should be considering. There is an optional “Pro” version of the plugin which is highly recommended for any site relying heavily on the calendar feature.

For websites that do not need a robust calendar feature the basic/free version of The Events Calendar should suffice. This basic version, however, has some drawbacks. The most notable of these is that the sort order of events/posts in the admin view defaults to the date of the event. This is SUPER annoying – especially if you have lots of events. What’s worse is that the developers seemed to have stripped out the standard “sort by date modified” column from the admin panel. So if you have an event that happens a year from now and you add it to the calendar but you want to go back and edit it the post could be buried behind a bunch of events that happen sooner.

The Events Calendar Admin Sort Posts by Date View

In order to fix this, we are going to change the default sort order of the posts and add a “Sort by Date Modified” column to our admin view.


/* *************** SETUP THE SORT POSTS BY MODIFIED DATE IN THE EVENTS CALENDAR PLUGIN *************** */

			// Add the custom column to the post type
			add_filter( 'manage_tribe_events_posts_columns', 'mwx_events_custom_column' );
			function mwx_events_custom_column( $columns ) {
			    $columns['modified'] = 'Last Modified';

			    return $columns;
			}

			// Add the data to the custom column
			add_action( 'manage_tribe_events_posts_custom_column' , 'mwx_events_custom_column_data', 10, 2 );
			function mwx_events_custom_column_data( $column, $post_id ) {
			    switch ( $column ) {
			        case 'modified' :
						$date_format = 'Y/m/d';
						$post = get_post( $post_id );
						echo get_the_modified_date( $date_format, $post ); // the data in the column
			            break;
			    }
			}

			// Register the modified date column as sortable
			function mwx_events_custom_column_sortable( $columns ) {
			    $columns['modified'] = 'post_modified';
			    return $columns;
			}
			add_filter( 'manage_edit-tribe_events_sortable_columns', 'mwx_events_custom_column_sortable' );



/* *************** SETUP THE DEFAULT ADMIN SORT ORDER OF THE EVENTS CALENDAR PLUGIN *************** */

	function mwx_events_default_sort_order( $wp_query ) {
	  if (is_admin()) {
	    // Get the post type from the query
	    $post_type = $wp_query->query['post_type'];
	    if ( $post_type == 'tribe_events') {  // Set our post type here
	      $wp_query->set('orderby', 'modified');
	      $wp_query->set('order', 'DESC');
	    }
	  }
	}
	add_filter('pre_get_posts', 'mwx_events_default_sort_order');

To get this to work you just add the above code to your functions.php file in your theme and should be all set. A better way to handle this, though, would be to add it as a plugin. I have packaged this up for you and you can download the basic plugin here:

The plugin makes it easier to add or remove from sites based on whether or not you are using The Events Calendar plugin.

Leave a Reply

Get in Touch

Please fill out the form below and we will get back to you ASAP

  • This field is for validation purposes and should be left unchanged.