• I’m puzzled with this problem. Why this simple piece of code is not returning all the child categories of the parent category? It’s only returning one subcategory instead of all of them.

    I’ve added the code in the beginning of a category-my-slug.php file.

    $get_categories_args = array(
    'child_of' => '35'
    );
    $sub_categories = get_categories($get_categories_args);
    print "Subcategories:<br />";
    print_r ($sub_categories);

    And yes, the ID 35 is correct and the subcategories do exist. ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • @tommip: Do all of the subcategories (and not just the one which is being returned) have published posts assigned to them?

    Thread Starter tommip

    (@tommip)

    Thanks girlieworks! That was the issue! I didn’t realize the posts are affecting this. Not all subcategories had published posts. I can live with this feature. ??

    Is there a way to force a category listing of all categories, regardless of published posts?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘get_categories is not returning all child categories’ is closed to new replies.