Skip to content

Instantly share code, notes, and snippets.

@mgratch
Created September 24, 2015 19:20
Show Gist options
  • Save mgratch/848a949f5749c4e536ed to your computer and use it in GitHub Desktop.
Save mgratch/848a949f5749c4e536ed to your computer and use it in GitHub Desktop.
override a template file in a theme
function include_template_files() {
global $wp;
$plugindir = dirname( __FILE__ );
if (is_home() || is_front_page()) {
$templatefilename = 'home.php';
$template = $plugindir . '/theme_files/' . $templatefilename;
include($template);
exit;
}
if (is_post_type_archive('special')){
$templatefilename = 'archive-special.php';
$template = $plugindir . '/theme_files/' . $templatefilename;
include($template);
exit;
}
}
add_action('template_redirect', 'include_template_files');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment