How do I get the category children without getting the children of children?
-
Hi,
I’m trying to make a theme which shows an overview of child categories with title, link and description when entering a category archive. However, I only want to show child categories one level below the current category, and not the children of child categories. How do I do that?
I’ve tried the following:
$childcategories = get_categories('child_of=' . $cat . '&hide_empty=1'); foreach ($childcategories as $childcategory) { if (in_category($childcategory)) { echo '<li><h2><a href="'; bloginfo('url'); echo '/category/'.$cat_id->category_nicename.'/'.$childcategory->category_nicename.'">'; echo $childcategory->cat_name . '</a></h2>'; echo '<p>'.$childcategory->category_description.'</p>'; echo '<p>'.$childcategory->cat_ID.'</p>'; echo '</li>'; } }
… which seems to work perfectly in MAMP for mac but fails in XAMPP for win as well as on my debian server.
What am I doing wrong? Can anybody help?
Thanks in advance.
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘How do I get the category children without getting the children of children?’ is closed to new replies.