Created
September 24, 2015 19:20
-
-
Save mgratch/848a949f5749c4e536ed to your computer and use it in GitHub Desktop.
override a template file in a theme
This file contains hidden or 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
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