Skip to content

Instantly share code, notes, and snippets.

@coderaaron
Created February 3, 2017 21:58
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 coderaaron/56ac7649fcb770cdde6eb4740c3fc37f to your computer and use it in GitHub Desktop.
Save coderaaron/56ac7649fcb770cdde6eb4740c3fc37f to your computer and use it in GitHub Desktop.
Load template from theme first, fall back to plugin template
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