Skip to content

Instantly share code, notes, and snippets.

@cliffordp cliffordp/functions.php
Last active Feb 7, 2020

What would you like to do?
Override The Events Calendar's V2 Views from a custom plugin location
* Add your own plugin as a template override location for The Events Calendar, Event Tickets, and related plugins. Only
* for TEC's V2 Views and ET's addons/overrides of TEC's V2 Views. Still need the old snippet for overriding ET's files.
* Each custom array's `path` is whatever you want it to be (i.e. customizable) up until the 'v2' part of each
* template's override path. We chose to keep it as `tribe/events` and `tribe/tickets` for simplicity.
* So if the TEC location for a view is:
* /wp-content/plugins/the-events-calendar/src/views/v2/list/event/featured-image.php
* Then this plugin's override location would be:
* /wp-content/plugins/MY-PLUGIN/tribe/events/list/event/featured-image.php
* And the theme's override location would be:
* /wp-content/themes/YOUR-CHILD-THEME/tribe/events/v2/list/event/featured-image.php
* FYI: Parent/Child Themes will override this custom plugin's override. Use your own custom code with the
* `tribe_template_theme_path_list` filter instead of this snippet to trump theme overrides if you must, but that is not
* typical best practice, although it may be necessary in order to override a theme that comes with V2 Views overrides
* (e.g. Avada) that you want to override.
* @link This snippet is only for V2 Views.
* @link Similar functionality for pre-TEC v5.x (not V2 views) or for ET.
* @link Official article with all the details.
* @see \Tribe__Template::get_template_path_list()
* @param array $folders Array of data for loading locations.
* @return array
function tribe_v2_additional_plugin_template_locations( $folders ) {
// Example: /app/public/wp-content/plugins/my-plugin/tribe/
$my_base_path = trailingslashit( plugin_dir_path( __FILE__ ) . 'tribe' );
* Custom loading location for overriding The Events Calendar's templates from within this plugin.
$folders['my_plugin_tec'] = [
'id' => 'my_plugin_tec',
'priority' => 5, // TEC is 20, ET is 17, so do something earlier, like 5
'path' => $my_base_path . 'events', // Example: /app/public/wp-content/plugins/my-plugin/tribe/events
* Custom loading location for overriding Event Tickets' addons/overrides for TEC's v2 views.
* Still need to use the old/non-v2 snippet to override ET's other template files.
$folders['my_plugin_et'] = [
'id' => 'my_plugin_et',
'priority' => 5, // TEC is 20, ET is 17, so do something earlier, like 5
'path' => $my_base_path . 'tickets', // Example: /app/public/wp-content/plugins/my-plugin/tribe/tickets
return $folders;
add_filter( 'tribe_template_path_list', 'tribe_v2_additional_plugin_template_locations' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.