Last active
January 26, 2018 23:17
-
-
Save hawkidoki/fdc57c2bc463e75db9feb27f68bc1b46 to your computer and use it in GitHub Desktop.
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 | |
// Post Type Subpages: Templates | |
add_filter('template_include', 'hwk_ptsp_template'); | |
function hwk_ptsp_template($template){ | |
if( !($post_id = get_the_ID()) || !($post_types = hwk_ptsp_get_post_types()) ) | |
return $template; | |
foreach($post_types as $post_type){ | |
if(!is_singular($post_type['post_type'])) | |
continue; | |
foreach($post_type['pages'] as $page){ | |
// Template de la Page par défaut | |
if( get_query_var($page['name']) && ($new_template = locate_template(array($page['template']))) ) | |
return $new_template; | |
} | |
} | |
return $template; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment