I'm writing a plugin that creates a cpt.
I can include a template for viewing a single instance of the cpt using the single_template
filter. And have it look for a template overload in the theme.
function my_cpt_single_template( $single_template ) {
global $post;
if ( $post->post_type == 'cpt' ) {
$theme_template = locate_template('single-cpt.php');
if( file_exists( $theme_template ) )
$single_template = $theme_template;
else
$single_template = PLUGIN_DIR . '/templates/single-cpt.php';
}
return $single_template;
}
add_filter( 'single_template', 'mp_cpt_single_template' );
But this loads a template that doesn't take into account whatever the theme might be doing in single.php
So is there a way to just inject part of the current single-cpt.php into the theme's single.php? In a way that the template part is overloadable from the theme?
Filtering on the_content
means the markup is hard-coded into the filter function, yes?
So users would have to hack that function rather than overload the template part and adjust as necessary,