Opened 19 years ago
Closed 18 years ago
#2481 closed defect (bug) (wontfix)
Cannot display hierarchical categories list of all blog's categories (including children)
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | minor | Version: | 2.0.1 |
Component: | Template | Keywords: | |
Focuses: | Cc: |
Description
When trying to display a hierarchical categories list including children, one could write the following PHP line in his/her theme:
wp_list_cats('hierarchical=1&children=1&child_of=0');
Since the parent category of all the other categories is 0, we had to set child_of to zero.
However, it appears the wp_list_cats() function uses the value 0 of child_of as both an integer value to limit the categories display to a given parent category (here, we want to limit it to category 0) AND as a boolean value, meaning 0 means "false" and the children of category 0 won't be displayed.
To fix this issue, another parameter should be added or a different value for child_of should be used.
Change History (3)
#1
@
19 years ago
- Keywords changed from template,theme,category,categories,hierarchical,parent,child,children,child_of,list,display to template theme category categories hierarchical parent child children child_of list display
#3
@
18 years ago
- Keywords template theme category categories hierarchical parent child children child_of list display removed
- Resolution set to wontfix
- Status changed from new to closed
Closing as wontfix for two reasons.
wp_list_cats
has been deprecated in favour ofwp_list_categories
- It's not possible to create a category with an ID of 0 (unless you directly edit the DB, then you're creating your own problems...)
Can't duplicate this problem at 2.0.1 or 2.0.1 alpha1 but I may not understand the issue.
Using your example
wp_list_cats('hierarchical=1&children=1&child_of=0')
or
wp_list_cats('hierarchical=1&children=1')
or
wp_list_cats()
returns the same thing--all categories (see Note).
Note: If a parent category has no posts, then neither the parent or its children will display using the above examples. Using hide_empty=0 would force them to display.
Interestingly, this returns no categories;
wp_list_cats('hierarchical=1&children=1&child_of=')