Create theme files for plugin

Basically I’ve made a plugin to create a new post type (event).

Now I want to create a single-event.php layout file.

Read More

I don’t want to have to stick it in the theme folder, I want to put it into my plugin folder. How do I make wordpress know its there?

Thanks

Related posts

Leave a Reply

1 comment

  1. Here is the code that will let you return your single-event.php if the post type is event:

    function my_event_template($single_template) {
        global $post;
    
        if ($post->post_type == 'event') {
            return dirname( __FILE__ ) . '/single-event.php';
        return $single_template;
    }
    
    add_filter( "single_template", "my_event_template" ) ;