Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#17316 closed defect (bug) (fixed)

Don't 404 on empty post type archives

Reported by: jfarthing84's profile jfarthing84 Owned by: nacin's profile nacin
Milestone: 3.2 Priority: normal
Severity: normal Version: 3.1
Component: Posts, Post Types Keywords: needs-testing needs-patch
Focuses: Cc:


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)

class-wp.php.diff (688 bytes) - added by jfarthing84 13 years ago.
17316.diff (729 bytes) - added by markmcwilliams 13 years ago.
17316.patch (702 bytes) - added by scribu 13 years ago.
check only get_queried_object()

Download all attachments as: .zip

Change History (20)

#1 @markmcwilliams
13 years ago

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? :)

#2 @jfarthing84
13 years ago

Yep, my bad.

#3 @scribu
13 years ago

  • Milestone changed from Awaiting Review to 3.2
  • Version changed from 3.2 to 3.1

#4 @scribu
13 years ago

Actually, couldn't we only check $wp_query->get_queried_object() && !is_paged() ?

#5 follow-up: @jfarthing84
13 years ago

We very well could, since if there is a queried object, it shouldn't be a 404.

13 years ago

check only get_queried_object()

#6 @dalesaurus
13 years ago

  • Cc dale.liszka@… added

#7 in reply to: ↑ 5 @nacin
13 years ago

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().

#8 @scribu
13 years ago

So? In which case would we want to send a 404 header that would also have queried_object set?

#9 @ryan
13 years ago

  • Milestone changed from 3.2 to Future Release

Punted per bug scrub.

#10 @nacin
13 years ago

  • Keywords commit added
  • Milestone changed from Future Release to 3.2

Restoring per bug scrub. Suggest commit on 17316.diff.

#11 @aaroncampbell
13 years ago

+1 That seems like the most conservative fix for now.

#12 @johnjamesjacoby
13 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.

Last edited 13 years ago by johnjamesjacoby (previous) (diff)

#13 @nacin
13 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In [18192]:

Don't 404 for empty post type archives. props markmcwilliams, jfarthing84, fixes #17316.

#14 @gazpachu
13 years 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.

#15 @SergeyBiryukov
13 years ago

  • 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.

#16 @scribu
13 years 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.

#17 @nacin
13 years 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.

Note: See TracTickets for help on using tickets.