Opened 14 years ago
Closed 11 years ago
#15626 closed enhancement (wontfix)
get_terms bug: pad_counts doesn't work if you specify parent
Reported by: | yeswework | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.8 |
Component: | Taxonomy | Keywords: | |
Focuses: | Cc: |
Description
I'm not sure if this is related to #13176 or not.
Anyway, to explain the bug with an example:
Let's say you want to retrieve, via get_terms, a list of the top level categories only (by setting parent=0), but that you want the counts to include any posts assigned to subcategories too (pad_counts=1).
$categories=get_terms('category', 'pad_counts=1&parent=0');
This doesn't work: as soon as you specify parent=, it stops including the subcategory count within the parent categories. A bug, surely?
I've traced the cause to line 842 of taxonomy.php, where it checks
if ( !== $argsparent?)
and if so, sets pad_counts back to 0.
Why is that check needed at all?
Change History (8)
#1
in reply to:
↑ description
@
14 years ago
#2
@
14 years ago
- Keywords 2nd-opinion added
- Milestone changed from Awaiting Review to Future Release
- Version changed from 3.1 to 2.8
Is this a regression? The "Version" is the version you are using, but line 841 is no longer this in 3.1.
Moving the version back to 2.8 at the earliest, as that was the last commit in that area: [11476].
#4
@
14 years ago
- Type changed from defect (bug) to enhancement
- Version changed from 3.0.1 to 2.8
To clarify -- "Version" is actually the earliest known version, so we know when a bug was introduced or how far down it affects. Generally, that will be your own version, but I quickly traced it back much farther. :-)
This also appears to be by design, so I'm setting it as an enhancement and 2nd-opinion.
#5
@
14 years ago
- Cc yeswework added
okay, great. thanks for your help. I found a simple enough workaround for now, but I'm interested to see whether someone can explain why it would have been by design.
#6
@
14 years ago
- Cc mark@… added
Even if this is not a bug (which I would dispute!), the related #17365 is.
correction: line 841 of taxonomy.php