function myTemplateSelect() {
if(is_category() && !is_feed()) {
if (is_category(get_cat_id('news')) || cat_is_ancestor_of(get_cat_id('news'), get_query_var('cat'))) {
load_template(TEMPLATEPATH . '/category-news.php');
exit;
}
if (is_category(get_cat_id('cases')) || cat_is_ancestor_of(get_cat_id('cases'), get_query_var('cat'))) {
load_template(TEMPLATEPATH . '/category-cases.php');
exit;
}
if (is_category(get_cat_id('stati')) || cat_is_ancestor_of(get_cat_id('stati'), get_query_var('cat'))) {
load_template(TEMPLATEPATH . '/category-stati.php');
exit;
}
}
}
add_action('template_redirect', 'myTemplateSelect');
Использование одного шаблона для категории и её подкатегории
|
PHP