views:

91

answers:

2

I use the following code in my Single.php file to grab show a different single template file based on what the user is viewing.

<?php
    if (in_category('Portfolio')) {
        include (TEMPLATEPATH . '/single-work.php');
    }
    elseif (in_category('Blog')) {
        include (TEMPLATEPATH . '/single-blog.php');
    }
?>

The problem is that I am using Child Themes and therefore it will try to include files from the parent theme instead of the child theme. How do I get it to include from the child theme instead?

+1  A: 

Confusingly you have to use STYLESHEETPATH instead of TEMPLATEPATH.

Richard M
A: 

Awesome that works great. While I'm showing that code though, how would I get it show single-blog.php for all child categories of Blog without having to list them all like this:

elseif (in_category('Blog') || in_category('Sub-Blog')) || in_category('Sub-Blog2'))
Cameron
That is a bit more complicated, you'd have to do something like:`in_category('Blog') || in_category(get_term_children(get_cat_id('Blog'), 'category'))`
Richard M
This shouldn't be an answer to your question, should be a comment for Ricard M's answer http://stackoverflow.com/questions/2195464/wordpress-child-theme/2195644#2195644. Remember to check the answer as "accepted" if it resolves your problem. Welcome to SO!
GmonC