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

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

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

1
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" ) ;

Leave a Reply

Your email address will not be published. Required fields are marked *