WordPress.org

Forums

Get subcategory to use its parents category template (1 post)

  1. leeryloons
    Member
    Posted 2 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic