#55834 closed defect (bug) (duplicate)
wp_list_categories not working correctly since 6.0 upgrade
Reported by: | ericcorbett2 | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Taxonomy | Keywords: | |
Focuses: | Cc: |
Description
Since upgrading to version 6.0 the wp_list_categories function is broken, specifically the 'child_of' parameter to $args is ignored.
Change History (8)
#2
follow-up:
↓ 3
@
2 years ago
I think you misunderstand.
I'm talking about invoking wp_list_categories with the &arg array.
And I'm not talking posts, but pages.
#3
in reply to:
↑ 2
;
follow-up:
↓ 5
@
2 years ago
- Resolution set to worksforme
- Status changed from new to closed
Replying to ericcorbett2:
I think you misunderstand.
I'm talking about invoking wp_list_categories with the &arg array.
And I'm not talking posts, but pages.
Scrub all that.
There was a coding error on my part that must have lain dormant until the 6.0 upgrade. I'm sorry to have wasted your time.
#4
@
2 years ago
- Keywords reporter-feedback removed
- Milestone Awaiting Review deleted
No worries, thanks for the follow-up!
#5
in reply to:
↑ 3
;
follow-up:
↓ 6
@
2 years ago
I'm sorry to bother you, but what was the error in your code?
My wp_list_categories output also is broken after 6.0 update. Even get_terms ignoring 'child_of' parameter, despite the fact that I have set 'hide_empty' to false.
Replying to ericcorbett2:
Replying to ericcorbett2:
I think you misunderstand.
I'm talking about invoking wp_list_categories with the &arg array.
And I'm not talking posts, but pages.
Scrub all that.
There was a coding error on my part that must have lain dormant until the 6.0 upgrade. I'm sorry to have wasted your time.
#6
in reply to:
↑ 5
@
2 years ago
Replying to Quixtar:
I'm sorry to bother you, but what was the error in your code?
My wp_list_categories output also is broken after 6.0 update. Even get_terms ignoring 'child_of' parameter, despite the fact that I have set 'hide_empty' to false.
Replying to ericcorbett2:
Replying to ericcorbett2:
I think you misunderstand.
I'm talking about invoking wp_list_categories with the &arg array.
And I'm not talking posts, but pages.
Scrub all that.
There was a coding error on my part that must have lain dormant until the 6.0 upgrade. I'm sorry to have wasted your time.
I'm not entirely certain to be honest, as I was using the ob_start() function incorrectly, which complicated things.
What seems to have fixed things though was changing the 'hide_empty' => 1, to 'hide_empty' => false.
Here's my working $args:
$atts = array( 'child_of' => $id, 'current_category' => 0, 'depth' => 0, 'echo' => 0, 'exclude' => '', 'exclude_tree' => '', 'feed' => '', 'feed_image' => '', 'feed_type' => '', 'hide_empty' => false, 'hide_title_if_empty' => false, 'hierarchical' => true, 'order' => 'ASC', 'orderby' => 'name', 'separator' => '', 'show_count' => 0, 'show_option_all' => '', 'show_option_none' => __( 'No categories' ), 'style' => 'list', 'taxonomy' => 'category', 'title_li' => '', 'use_desc_for_title' => 1, );
Hope that helps.
#7
follow-up:
↓ 8
@
2 years ago
- Resolution changed from worksforme to duplicate
It looks like #55837 is the underlying issue here.
Hi @ericcorbett2 and welcome to trac!
I have tried to reproduce this problem but am unable to I am afraid.
wp_list_categories( ['child_of' => 2] );
is showing the category I have set up as a subcategory of category2
:By default
wp_list_categories()
will hide categories that do not contain any posts unless you include the argument'hide_empty' => false
.Are you able to confirm your child categories have posts or you have included above?
Testing notes
Created two categories
Categorized
(given the id2
, no parent)Sub-categorized
(given the ID3
,categorized
as parent)Ran the following code
wp_list_categories( ['child_of' => 2] )
-- no categories display due to lack of postswp_list_categories( ['child_of' => 2, 'hide_empty' => false] );
--Sub-categorized
shown as expectedCreated a post and assigned it to
sub-categorized
and re-ran the following codewp_list_categories( ['child_of' => 2] )
--Sub-categorized
shown as expectedwp_list_categories( ['child_of' => 2, 'hide_empty' => false] );
--Sub-categorized
shown as expected