Support » Themes and Templates » Get subcategory to use its parents category template

  • Please help me with this problem. What I’m trying to do is to get a certain subcategory to use its parents category theme. To do that I added this function (found in some forum) to my function.php file:

    function myTemplateSelect() {
        if (is_category() && !is_feed()) {
            if (is_category(get_cat_id('stuff')) || cat_is_ancestor_of(get_cat_id('stuff'), get_query_var('cat'))) {
    
                load_template(TEMPLATEPATH . '/category-stuff.php');
                exit;
            }
        }
    }
    
    add_action('template_redirect', 'myTemplateSelect');

    My subcategory now uses the category-stuff template. That’s fine until I found out that all my other categories (not even subcategories) use the category-stuff template as well 🙁

    Why?

  • The topic ‘Get subcategory to use its parents category template’ is closed to new replies.