Created
February 3, 2017 21:58
-
-
Save coderaaron/56ac7649fcb770cdde6eb4740c3fc37f to your computer and use it in GitHub Desktop.
Load template from theme first, fall back to plugin template
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
add_filter( 'template_include', array( self::$instance, 'ppi_load_single_template' ), 99 ); | |
... | |
function ppi_load_single_template( $template ) { | |
... | |
if ( is_singular( 'things' ) ) { | |
// look in child or parent themes for template files first | |
if ( $theme_template = locate_template( 'single-items.php' ) ) { | |
$template = $theme_template; | |
} else { | |
$template = self::$directories['templates'] . 'single-items.php'; | |
} | |
} | |
return $template; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment