Get List of subcategory
wordpress, wordpress-theming
Solution
Is that category empty? By default WordPress hides emptr categories. try:
$categories = get_categories('child_of=2&hide_empty=0');
Edit: Fixed, thank you @Stoep
Problem
I have this category on my wordpress: ``` Test1 - Sub1OfTest1 - Sub2OfTest1 Test2 - Sub1OfTest2 - Sub2OfTest2 ``` Now iam at url: `http://localhost/wordpress/category/test1` I write the following code on file `category-test1.php` ``` <?php $categories = get_categories('child_of=2'); print_r($categories); foreach ($categories as $category) : ?> <div class="qitem"> <a href="<?php get_category_link( $category->term_id ); ?>" title="<?php echo $category->name; ?>"> <?php echo $category->name; ?> </a> <h4> <span class="caption"> <?php echo $category->name; ?> </span> </h4> <p> <span class="caption"> <?php echo $category->description; ?> </span> </p> </div> <?php endforeach; ?> ``` I'm trying to show sub category of Test1 but the code only return array(). What did I miss?