Answer the question
In order to leave comments, you need to log in
How to determine the nesting level of a Wordpress category?
The situation is this:
there are categories
Catalog
- Level 2
- Level 3
- Record
How to write a condition for category.php
to display different code at each category level?
Answer the question
In order to leave comments, you need to log in
$current_cat_id = get_query_var('cat');
$child = get_category($current_cat_id);
$level2 = $child->parent;
$child2 = get_category($level2);
$level3 = $child2->parent;
if(is_category(6)){
include "catalog.php";
} else if ($level2 == 6){
include "catalog_level2.php";
} else if ($level3 == 6){
include "catalog_level3.php";
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question