2015-03-04 7 views

ответ

1

Put это в functions.php вашей темы:

function is_category_level($depth){ 
    $current_category = get_query_var('cat'); 
    $my_category = get_categories('include='.$current_category); 
    $cat_depth=0; 

    if ($my_category[0]->category_parent == 0){ 
     $cat_depth = 0; 
    } else { 

     while($my_category[0]->category_parent != 0) { 
      $my_category = get_categories('include='.$my_category[0]->category_parent); 
      $cat_depth++; 
     } 
    } 
    if ($cat_depth == intval($depth)) { return true; } 
    return null; 
} 

и использовать эту функцию в category.php так:

<?php 
if(is_category_level('1')){ 
    // do stuff 
} 
?>