Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Re-route template for hierarchical custom post types
<?php
add_filter( 'page_template', 'pilau_hierarchical_cpt_template' );
/**
* Re-route template for hierarchical custom post types
*
* Not sure why this is needed????
*
* @param string $template
* @return string
*/
function pilau_hierarchical_cpt_template( $template ) {
if ( get_post_type() != 'page' ) {
$template = trailingslashit( get_stylesheet_directory() ) . 'single-' . get_post_type() . '.php';
}
return $template;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.