As the title says, I am creating a Sage 10 theme (we are NOT using bedrock). This website requires a custom post type of "speaker" which will also come with a single-speaker.php page to display the information. All of this functionality was written within a plugin but I am having trouble getting the page template to populate within the theme.
The custom post type and metabox do work, and I can get the values as well. However, the single-speaker.php page will not work. I have tried:
add_filter('single_template', 'speaker_single_template');
function speaker_single_template($single) {
global $post;
/* Checks for single template by post type */
if ( $post->post_type == 'speaker' ) {
if ( file_exists( SPEAKER_PLUGIN_URL . '/templates/single-speaker.php' ) ) {
return SPEAKER_PLUGIN_URL . '/templates/single-speaker.php';
}
}
return $single;
}
I would have thought this filter would have pushed the template page into the theme, but it simply is not.
Is there a problem where Sage uses blade directives? I had assumed the default php pages would still work.
2
Answers
You can use
single_template
filter hook.Try this:
Tip:
Confirm your constant
SPEAKER_PLUGIN_URL
is actually what you expect it to be.