Last active
October 4, 2023 17:39
-
-
Save yanknudtskov/c23ea7f308ccfcc42374f339947a8e95 to your computer and use it in GitHub Desktop.
Override The Events Calendar Plugin templates for events.Remember to copy the files/wp-content/themes/enfold/config-events-calendar/views/default-template.php/wp-content/themes/enfold/config-events-calendar/views/single-event.phpinto/wp-content/themes/enfold_child_theme_by_yanco/views/default-template.php/wp-content/themes/enfold_child_theme_by_…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'after_setup_theme', 'enfold_child_theme_code' ); | |
function enfold_child_theme_code() { | |
if(is_child_theme()) remove_action('tribe_events_template', 'avia_events_template_paths', 10, 2); | |
} | |
add_action('tribe_events_template', 'avia_events_template_paths_mod', 10, 2); | |
function avia_events_template_paths_mod($file, $template) | |
{ | |
$redirect = array('default-template.php', 'single-event.php'); | |
if(in_array($template, $redirect)) | |
{ | |
$file = get_stylesheet_directory() . "/tribe-events/views/".$template; | |
} | |
return $file; | |
} |
Thanks :-)
Typo line 5, should be 'avia_events_template_paths'
Otherwise thanks!
To ensure safe usage, this code is designed to prioritize template files in your child theme. If no custom template files exist in the child theme, it will fall back to using the template files from the Enfold main theme.
add_action('after_setup_theme', 'enfold_child_theme_code');
function enfold_child_theme_code() {
if (is_child_theme()) {
remove_action('tribe_events_template', 'avia_events_template_paths', 10, 2);
}
}
add_action('tribe_events_template', 'avia_events_template_paths_mod', 10, 2);
function avia_events_template_paths_mod($template, $template_name) {
$child_theme_path = get_stylesheet_directory() . "/tribe-events/views/" . $template_name;
$parent_theme_path = get_template_directory() . "/config-events-calendar/views/" . $template_name;
if (file_exists($child_theme_path)) {
return $child_theme_path;
} elseif (file_exists($parent_theme_path)) {
return $parent_theme_path;
}
return $template;
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Typo line 5, should be 'avia_events_template_paths'
Otherwise thanks!