Using Plugin Templates in Sage 10

Hello,

I am creating a Sage 10 theme (without bedrock) and also creating a few plugins to increase functionality by introducing new post types and single-{$post-type}.php pages. Using normal methods of integrating plugin templates through functions such as add_filter(‘single_template’) does not work.

How am I able to use templates from plugins within Sage 10 themes?

Howdy!

Sharing your code that isn’t working would be a good start.

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;

}

Is the code recommended to add templates from plugins to themes, but it does not work.

I have also tried making a single-speaker.php file in the root of the theme, which is how wordpress works by default, but that also did not work. The only way of me creating a single page for the custom post type is to create the content-single-speaker.blade.php file within the theme --which is not helpful because the template needs to come from the plugin.