#21479 closed defect (bug) (wontfix)
Twenty Twelve: hide category and tag output in post meta if only 1 term
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Bundled Theme | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: | ryan@…, joachim.kudish@… |
Description
Props ryanimel and iandstewart for the report and idea for fix.
First patch attached.
Attachments (6)
Change History (26)
lancewillett — 10 months ago
- Cc joachim.kudish@… added
In 21479.2.patch, I've simplified and cleaned up the function in several ways:
- I don't think it helps anything to cache the function in a transient as get_categories calls get_terms which has caching built-in
- Renamed the function to 'twentytwelve_is_categorized_site' to be a bit more descriptive about what it does
- Renamed the variable $all_the_cool_cats to $non_empty_categories to be a bit more descriptive about it is
- Simplified the if statements
iandstewart — 10 months ago
Modifying ryanimel's patch to flush out the cool cats when a user delete's categories too (and props to ryanimel for catching that right away)
comment:3
iandstewart — 10 months ago
jkudish FTW. Much simpler.
comment:5
lancewillett — 10 months ago
- Owner set to lancewillett
- Resolution set to fixed
- Status changed from new to closed
In [21444]:
comment:6
lancewillett — 10 months ago
In [21449]:
comment:7
lancewillett — 10 months ago
In [21489]:
- Resolution fixed deleted
- Status changed from closed to reopened
This looks like it would be running extra queries on the frontend. We should be sure they are necessary.
! empty( $categories_list ) can simply be $categories_list. Also, count() is unnecessary when empty() is already there.
comment:10
in reply to:
↑ 9
lancewillett — 9 months ago
Replying to nacin:
! empty( $categories_list ) can simply be $categories_list.
Agreed.
Also, count() is unnecessary when empty() is already there.
The check is supposed to return false if only 1 category exists. So, the check should be count( $non_empty_categories ) < 2 instead, right?
SergeyBiryukov — 9 months ago
comment:11
follow-up:
↓ 13
SergeyBiryukov — 9 months ago
We could use wp_count_terms(), which performs a faster query (SELECT COUNT(*) instead of requesting all the category data, 0.8ms vs. 4.0ms on my install).
21479.4.patch also simplifies the $tag_list check.
comment:12
obenland — 9 months ago
21479.5.diff builds on @SergeyBiryukov's patch, further simplifying the is_categorized() check.
comment:13
in reply to:
↑ 11
lancewillett — 9 months ago
- Keywords commit removed
Replying to SergeyBiryukov:
We could use wp_count_terms(), which performs a faster query (SELECT COUNT(*) instead of requesting all the category data, 0.8ms vs. 4.0ms on my install).
Nice. :)
comment:14
follow-up:
↓ 16
lancewillett — 9 months ago
Ryan and Ian — can you weigh in on why you think this UX improvement is worth adding extra queries to each page load?
Discussing today in #wordpress-dev IRC Nacin is voting to remove this and "just live with Uncategorized."
comment:15
lancewillett — 9 months ago
If no votes for why the UX is important for the default theme to hide "Uncategorized" from display, we'll revert and punt this to a better fix on the core side, meaning only 1 category and it's named Uncategorized will be the same as having 0 categories on the front end.
Better to fix it in core for all themes than just one theme here.
comment:16
in reply to:
↑ 14
iandstewart — 9 months ago
Replying to lancewillett:
can you weigh in on why you think this UX improvement is worth adding extra queries to each page load?
It doesn't make sense to display only 1 category if every post is in that category. One category is no categories, imo. I think it's confusing for new users and worse, just plain ugly if that category is uncategorized -- though I'd feel the same way no matter what that one category was named. It's also annoying for users using WordPress as a small CMS for brochure sites where they may not be using any categories at all. We do it with tags, we should do it with categories.
+1 for this being in core and available for every theme -- with a new template tag. Themes need to be able to make markup for category lists conditional on there actually being categories to theme.
comment:17
ryanimel — 9 months ago
Better in core than a theme, absolutely. It would be nice if the theme could have it in, just for the sake of working that way sooner, but I understand not wanting to add extra queries. +1 for core too.
comment:18
lancewillett — 9 months ago
In [21543]:
comment:19
lancewillett — 9 months ago
- Resolution set to wontfix
- Status changed from reopened to closed
See #14901 for a possibly related discussion for hiding Uncategorized in front-end display.
Closing this as the solution should not be in the theme itself.
comment:20
SergeyBiryukov — 9 months ago
- Milestone 3.5 deleted

Patch from ryanimel