WordPress.org

Make WordPress Core

Opened 8 years ago

Last modified 8 years ago

#4870 closed defect (bug)

Bug in get_categories when asking for category children — at Initial Version

Reported by: hovenko Owned by: anonymous
Milestone: Priority: high
Severity: major Version: 2.2.2
Component: General Keywords: categories
Focuses: Cc:

Description

When asking for categories that are child of another category (cat1) and to
include empty categories I get different behaviour wether cat1 has children
or not.

Take the following code:

$cat_children   = get_categories(
        array(
                'child_of'      => 1,
                'hide_empty'    => false,
        );
);

print_r($cat_children);

Scenario 1:
I have the following categories:

1 - cat1 (no parent)
2 - cat2 (no parent)
3 - cat3 (parent:1)

In this case it prints out cat3.

Scenario 2:
I have the following categories:

1 - cat1 (no parent)
2 - cat2 (no parent)

In this case it prints out cat1 and cat2.

Expected behaviour is to get an empty list, simply because cat1
doesn't have any children.

Change History (0)

Note: See TracTickets for help on using tickets.