• Hi! This is my first post. I hope my poor english won’t be a problem so you can understand my doubt:

    I need that my client be able to create subcategories from administration zone which inherit the parent category’s template .

    Is it possible or I will have to set the templates when he need a new category?

    Thank U.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Sounds like a good idea for a plugin…

    Category Template Inheritor:
    download plugin | view source

    Download the plugin file, upload to your wp-content/plugins directory, and activate Category Template Inheritor under Plugins. Then just make sure you have a specific category template set up for a category with child categories you want this to work with.

    Is it possible to modify this plugin so that sub-sub-categories can inherit the template? I tried this modification but it didn’t seem to work:

    function szub_cat_template_inherit() {
    if(is_category()) {
    global $wp_query;
    $category = $wp_query->get_queried_object();
    if( $category->category_parent && $category->category_parent->category_parent )
    $template = TEMPLATEPATH . '/category-' . $category->category_parent->category_parent . '.php';
    elseif( $category->category_parent && file_exists(TEMPLATEPATH . '/category-' . $category->category_parent . '.php') )
    $template = TEMPLATEPATH . '/category-' . $category->category_parent . '.php';
    elseif( file_exists(TEMPLATEPATH . "/category-" . get_query_var('cat') . '.php') )
    $template = TEMPLATEPATH . "/category-" . get_query_var('cat') . '.php';
    elseif( file_exists(TEMPLATEPATH . "/category.php") )
    $template = TEMPLATEPATH . "/category.php";

    return $template;
    }
    }

    bricka, I’ll be releasing this plugin on my blog soon, and when I do I’ll look at how to incorporate an entire category hierarchy (parent category / child / child / child / etc) under one template. No guarantees!

    Old thread, but I modified the plugin to handle single template, rather than category template. I emailed it to you Kaf.

    Hey Kaf and Community,

    I am loving this plugin. Is there any word on the latest development and if it will be set so that a child to a child will inherent the parent category template. That would be awesome and save me even more category.phps.

    Thanks,
    Orion

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘May a category inherit template from its parent?’ is closed to new replies.