Using single.php from plugin folder instead of default template folder

I think a hook into template_include like described here could be a proper way to do this.

Code could be like this:

add_filter('template_include', 'my_plugin_templates');
function my_plugin_templates( $template ) {
    $post_types = array('post');

    if (is_singular($post_types)) {
        $template="path/to/singular/template/in/plugin/folder.php";
    }

    return $template;
}

Leave a Comment