Skip to content

Instantly share code, notes, and snippets.

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 hawkidoki/fdc57c2bc463e75db9feb27f68bc1b46 to your computer and use it in GitHub Desktop.
Save hawkidoki/fdc57c2bc463e75db9feb27f68bc1b46 to your computer and use it in GitHub Desktop.
<?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