Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bdeleasa/b2e8d2ce186b2ef5fe49d1526eb2b56d to your computer and use it in GitHub Desktop.
Save bdeleasa/b2e8d2ce186b2ef5fe49d1526eb2b56d to your computer and use it in GitHub Desktop.
Modifies The Events Calendar plugin event archive to include both present and past events. Also reorders the events so they are in revers chronological order.
<?php
/**
* The plugin bootstrap file
*
* This file is read by WordPress to generate the plugin information in the plugin
* admin area. This file also includes all of the dependencies used by the plugin,
* registers the activation and deactivation functions, and defines a function
* that starts the plugin.
*
* @link http://example.com
* @since 0.0.1
* @package The_Events_Calendar_Show_All_Events
*
* @wordpress-plugin
* Plugin Name: The Events Calendar - Show All Events
* Plugin URI: https://briannadeleasa.com
* Description: Modifies the event archive to include both present and past events.
* Version: 1.0.0
* Author: Brianna Deleasa
* Author URI: http://briannadeleasa.com
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: the-events-calendar-show-all-events
* Domain Path: /languages
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
add_action( 'tribe_events_pre_get_posts', 'tecsae_events_date_filter' );
/**
* Filters the Events archive to include all events, not just present events.
*
* @since 1.0.0
*
* @param $query object
* @return null
*/
function tecsae_events_date_filter( $query ) {
$query->set( 'start_date', '' );
$query->set( 'order', 'DESC' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment