WordPress.org

Ready to get started?Download WordPress

Forums

May a category inherit template from its parent? (6 posts)

  1. Public
    Member
    Posted 8 years ago #

    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.

  2. Kafkaesqui

    Posted 8 years ago #

    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.

  3. bricka
    Member
    Posted 8 years ago #

    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;
    }
    }

  4. Kafkaesqui

    Posted 8 years ago #

    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!

  5. samaritan
    Member
    Posted 7 years ago #

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

  6. startribe
    Member
    Posted 7 years ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic