Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Last active May 5, 2016 13:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pebblo/62749ca6a3951e860c474d6d206300a9 to your computer and use it in GitHub Desktop.
Save Pebblo/62749ca6a3951e860c474d6d206300a9 to your computer and use it in GitHub Desktop.
An example of how to add a custom directory to the locate_template function used within Event Espresso 4. This function simply adds a check for templates within /{wp_theme}/espresso/
<?php
//Do not include the opening php tag if you already have one open.
//This function adds an additional check to locate_template
function check_theme_directory_espresso_locate_template( $full_template_paths, $template_filename ) {
//Build the new full template path to check within /{wp_theme}/espresso/
$theme_espresso_template_dir = get_stylesheet_directory() . '/espresso/' . $template_filename;
//Add the new template path to the paths check by locate_template()
array_unshift( $full_template_paths, $theme_espresso_template_dir );
//Debug using Kint to output all paths that will be checked.
//d($full_template_paths);
return $full_template_paths;
}
add_filter( 'FHEE__EEH_Template__locate_template__full_template_paths', 'check_theme_directory_espresso_locate_template', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment