Is there a way to set all child themes of a specific parent to use a specific template? I found this code but it doesn’t work out of the box with Sage due to the base.php. Is there another way around it?
/**
* Automatically apply parent page template
*
* Inspired by: http://is.gd/wp_apply_parent_page_template
*/
function fstop_use_parent_page_template() {
// Checks if current post type is a page, rather than a post
if ( is_page() ){
$ancestors = get_post_ancestors( get_the_id() );
if ( $ancestors ) {
$parent_page_template = get_post_meta( end( $ancestors ), '_wp_page_template', true );
$template = TEMPLATEPATH . "/{$parent_page_template}";
$current_page_template = get_post_meta( get_the_id(),'_wp_page_template', true );
if ( file_exists( $template ) ) {
load_template( $template );
update_post_meta( get_the_id(), '_wp_page_template', $parent_page_template, $current_page_template );
exit;
}
} else {
return true;
}
}
}
add_action( 'template_redirect', 'fstop_use_parent_page_template' );