Opened 21 years ago
Closed 20 years ago
#2481 closed defect (bug) (wontfix)
Cannot display hierarchical categories list of all blog's categories (including children)
| Reported by: | kwa1975 | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Template | Version: | 2.0.1 |
| Severity: | minor | Keywords: | |
| Cc: | Focuses: |
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
@
21 years ago
- Keywords template,theme,category,categories,hierarchical,parent,child,children,child_of,list,display → template theme category categories hierarchical parent child children child_of list display
#3
@
20 years ago
- Keywords template theme category categories hierarchical parent child children child_of list display removed
- Resolution → wontfix
- Status new → closed
Closing as wontfix for two reasons.
wp_list_catshas 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...)
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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=')