Opened 10 years ago
Last modified 6 years ago
#31706 new defect (bug)
wp_list_categories for hierarchical taxonomy return wrong tree if orderby clause is used
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.1.1 |
Component: | General | Keywords: | reporter-feedback |
Focuses: | Cc: |
Description
My taxonomy is e.g.
-term 1 --subterm 1.1 ---subterm 1.1.1 --subterm 2.1 --subterm 3.1 -term 2 -term 3
and lets say i am on the 'term 1' page and i want to return all suterms. But when i run
$args = array( 'style' => 'list', 'title_li' => '', 'echo' => 0, 'hierarchical' => true, 'depth' => 2, 'taxonomy' => 'my_taxonomy', 'orderby' => 'count', 'order' => 'DESC', 'show_option_none' => '' ); $args['child_of'] = $current_term->term_id;
it return only
Subterm 1.1.1
Problem is that
'orderby' => 'count', 'order' => 'DESC',
when i put it out, it works as expected
BTW IMO wp_list_categories() need some bigger rewrite - it is probably the oldest code in WP :-). No filters, strange classes etc. especially comparing to similar wp_nav_menu. E.g. there is no class to parent LI (and it is often need to change e.g. for Bootstrap), nor any action or filter, the only way are some non-trivial preg_match on the full results or replacing the whole Walker, what is not optimal for forward and plugin compatibility
Note: See
TracTickets for help on using
tickets.
At a glance, it looks like your problem may be related to 'hide_empty'. I'm guessing Subterm 1.1.1 has posts, while the others do not. FWIW I'm not able to reproduce your bug with unit tests, but I'm not sure if I'm accurately recreating your setup.
Regarding the larger point: yes, it's old, and yes, it's an odd function, but generally we don't refactor for refactoring's sake. If you have specific requests for enhancements, please feel free to open tickets :)