您可以筛选template_include
并更换single-community.php
使用single-child-community.php
.
实例
add_filter( \'template_include\', function( $template ) {
if ( ! is_singular() )
return $template; // not single
if ( \'communities\' !== get_post_type() )
return $template; // wrong post type
if ( 0 === get_post()->post_parent )
return $template; // not a child
return locate_template( \'single-child-community.php\' );
});