Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
    
well dice the template system looks in the themes folder I think that this is the only way unless there is a filter. usually you put the register post type in the functions.pho –  xLRDxREVENGEx May 18 '11 at 17:05
add comment

1 Answer

up vote 6 down vote accepted

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" ) ;
share|improve this answer
    
I learned something today. Yay. thanks hameedullah i was not sure if there was a filter or not for this. –  xLRDxREVENGEx May 18 '11 at 17:51
1  
Glad that I was able to help you learn something new. :) –  Hameedullah Khan May 18 '11 at 18:09
    
mate this is brilliant. :) Thank you so much. –  Thomas Clayson May 19 '11 at 8:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.