Order by count with hierarchical
-
These are my categories along with the post counts:
A (3)
– B (4)
C (5)
– D (7)
E (6)
F (6)B and D are child categories of A and C respectively. When I choose to display them with order by as count in descending order, this is the result:
F (6)
E (6)
C (11)
– D (7)
A (7)
– B (4)I was hoping to see C, then A, then F/E, but it’s a different result. How do I get the result I need? I want the parent category with most post counts to be on the top. Even with tweaking the default WP category widget with the
widget_categories_args
filter, making$cat_args['orderby'] = 'count';
I get the same above result.Can anyone explain to me the logic of how this is a descending order by count? It’s possible they display the ones with no children first and then the ones with child categories, but the example below shows that is not so:
The output becomes more confusing to me when I add another child category. For example if I make F a child of D, I get this as the result of listing all categories ordered by count in DESC and shown as hierarchical
E (6)
C (16)
-D (12)
– F (6)
A (7)
-B (4)I do not understand the logic of how this is the correct result. Any help will be very much appreciated. Thanks in advance.
- The topic ‘Order by count with hierarchical’ is closed to new replies.