Opened 2 years ago
Closed 23 months ago
#17316 closed defect (bug) (fixed)
Don't 404 on empty post type archives
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 3.2 |
| Component: | Post Types | Version: | 3.1 |
| Severity: | normal | Keywords: | needs-testing needs-patch |
| Cc: | jeff@…, dale.liszka@… |
Description
Like the title says, we shouldn't 404 on empty post type archives, just like we don't 404 for empty tag, category, taxonomy or author archives. I have attached a patch.
Attachments (3)
Change History (20)
jfarthing84 — 2 years ago
comment:1
markmcwilliams — 2 years ago
markmcwilliams — 2 years ago
comment:2
jfarthing84 — 2 years ago
Yep, my bad.
- Milestone changed from Awaiting Review to 3.2
- Version changed from 3.2 to 3.1
Actually, couldn't we only check $wp_query->get_queried_object() && !is_paged() ?
comment:5
follow-up:
↓ 7
jfarthing84 — 2 years ago
We very well could, since if there is a queried object, it shouldn't be a 404.
comment:6
dalesaurus — 2 years ago
- Cc dale.liszka@… added
Replying to jfarthing84:
We very well could, since if there is a queried object, it shouldn't be a 404.
Not sure about that -- the conditionals removed in that patch, even when including is_post_type_archive(), is a subset of what's checked in get_queried_object().
So? In which case would we want to send a 404 header that would also have queried_object set?
comment:10
nacin — 2 years ago
- Keywords commit added
- Milestone changed from Future Release to 3.2
Restoring per bug scrub. Suggest commit on 17316.diff.
comment:11
aaroncampbell — 2 years ago
+1 That seems like the most conservative fix for now.
comment:12
johnjamesjacoby — 2 years ago
Tested 17316.diff against bbPress 2.0, with and without pretty permalinks, and works great. I think this is the desired result and would love for this to make it into 3.2. A few support topics of bbPress 2.0 beta have come through where an empty topics archive page 404's rather than shows the "No Topics found" feedback, and this alleviates that.
comment:13
nacin — 2 years ago
- Owner set to nacin
- Resolution set to fixed
- Status changed from new to closed
In [18192]:
comment:14
gazpachu — 23 months ago
- Keywords needs-testing needs-patch added; has-patch commit removed
- Resolution fixed deleted
- Status changed from closed to reopened
- Version changed from 3.1 to 3.2.1
The problem is still present:
"../news/archives/2010/09/29" redirects to a 404 Error because there are no posts that day.
- Version changed from 3.2.1 to 3.1
Please do not change the version number. It's there to track when the bug was introduced/reported.
comment:16
scribu — 23 months ago
I guess the wording wasn't clear. The idea was not to send a 404 HTTP header.
OTOH, sending a 200 HTTP header while loading the 404 template doesn't make much sense.
comment:17
nacin — 23 months ago
- Resolution set to fixed
- Status changed from reopened to closed
I don't see a bug here.
If there is one, open a new ticket.

I might be wrong, but shouldn't it be if ( ( is_tag() || is_category() || is_tax() || is_author() || is_post_type_archive() ) && $wp_query->get_queried_object() && !is_paged() ) { so that is_post_type_archive() is included within the if statement like the others? :)