Created
February 11, 2014 12:40
-
-
Save annalinneajohansson/8934129 to your computer and use it in GitHub Desktop.
WordPress: Add theme template from plugin if it doesn't exist in the theme folder.
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_filter( 'template_include', 'my_prefix_template' ); | |
function my_prefix_template( $template ) { | |
$template_filename = "foobar.php"; | |
if ( !file_exists( get_stylesheet_directory() . "/" . $template_filename ) ) { | |
$template = plugin_dir_path( __FILE__ ) . '/' . $template_filename; | |
} | |
return $template; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment