Make WordPress Core

Opened 14 years ago

Closed 9 years ago

#12981 closed defect (bug) (fixed)

odd behavior of exclude_tree parameter in wp_list_categories()

Reported by: tott's profile tott Owned by: tott's profile tott
Milestone: 4.4 Priority: normal
Severity: normal Version: 3.0
Component: Taxonomy Keywords: has-patch
Focuses: Cc:

Description

When running a query such as

<?php wp_list_categories('title_li=&exclude_tree=1234&orderby=name&order=ASC'); ?>

the exclude_tree parameter is not obeyed as [10276] introduced a change that would overwrite it with the exclude parameter.

Attachments (3)

exclude_tree.diff (545 bytes) - added by tott 14 years ago.
Possible patch for exclude_tree problem in wp_list_categories()
12981.diff (518 bytes) - added by webord 11 years ago.
Updating the .diff file for a refreshed one
12981.2.diff (1.5 KB) - added by MikeHansenMe 9 years ago.

Download all attachments as: .zip

Change History (19)

@tott
14 years ago

Possible patch for exclude_tree problem in wp_list_categories()

#1 @filosofo
14 years ago

  • Milestone changed from Unassigned to 3.0
  • Owner changed from filosofo to tott
  • Status changed from new to assigned
  • Version set to 3.0

#2 @filosofo
14 years ago

  • Keywords has-patch added

#3 @nacin
14 years ago

We've had this this way since 2.7.x at this point, though the patch looks good. I can't see anything it would break. Actually, exclude_tree was added in r10276, so it's never worked properly -- we can probably punt this in that case.

#4 @ryan
14 years ago

  • Milestone changed from 3.0 to 3.1

#5 @kevinB
14 years ago

  • Cc kevinB added

#6 @mhhenn
14 years ago

exclude_tree doesn't work when hide_empty=0, it must must be set to 1 (hide empty)...

#7 @nacin
13 years ago

  • Keywords 2nd-opinion added; exclude_tree wp_list_categories category removed
  • Milestone changed from Awaiting Triage to Future Release

@webord
11 years ago

Updating the .diff file for a refreshed one

#8 @webord
11 years ago

  • Keywords dev-feedback added

Refreshed the Patch.

#9 @wonderboymusic
11 years ago

  • Keywords needs-unit-tests added; 2nd-opinion removed
  • Milestone changed from Future Release to 3.7

Let's make a decision on the new patch

#10 @nacin
10 years ago

  • Milestone changed from 3.7 to 3.8

#11 @wonderboymusic
10 years ago

  • Milestone changed from 3.8 to Future Release

No unit tests

#12 @SergeyBiryukov
10 years ago

#28083 was marked as a duplicate.

#13 @MikeHansenMe
10 years ago

#28083 has unit tests

@MikeHansenMe
9 years ago

#14 @MikeHansenMe
9 years ago

  • Keywords needs-unit-tests removed

[attachment 12981.2.diff] adds a single unit test and refreshes the patch.

Version 0, edited 9 years ago by MikeHansenMe (next)

#15 @boonebgorges
9 years ago

  • Keywords dev-feedback removed
  • Milestone changed from Future Release to 4.4

Thanks for the patches. It looks like the reason for the if ( true === $hierarchical ) block is to ensure that excluding a category also excludes its descendants. So wiping out $r['exclude'] altogether doesn't seem like an acceptable strategy. We want to allow for the possibility that someone would pass exclude *as well as* exclude_tree, and have both of them (and their descendants) excluded from results.

#16 @boonebgorges
9 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 34696:

Fix 'exclude_tree' in wp_list_categories().

The 'exclude_tree' parameter must be compatible with 'hierarchical';
previously, 'hierarchical' canceled it out. This changeset also makes it so
that 'exclude_tree' is compatible with 'exclude'. When both are passed, and
'hierarchical' is true, the descendant trees of terms in both parameters will
be excluded from matched terms.

Props tott, webord, MikeHansenMe.
Fixes #12981.

Note: See TracTickets for help on using tickets.