<?php
/*
Plugin Name: Category Template Inheritor
Plugin URI: http://wordpress.org/support/topic/58382
Description: Allow sub-categories to acquire parent category's theme template.
Author: Kaf Oseo
Version: 0.1
Author URI: http://szub.net
Copyright (c) 2006 Kaf Oseo (http://szub.net)
Category Template Inheritor is released under the GNU General
Public License (GPL) http://www.gnu.org/licenses/gpl.txt
This is a WordPress plugin (http://wordpress.org).
*/
function szub_cat_template_inherit() {
if(is_category()) {
global $wp_query;
$category = $wp_query->get_queried_object();
if( $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;
}
}
add_filter('category_template', 'szub_cat_template_inherit');
?>