Make WordPress Core

Opened 15 years ago

Closed 15 years ago

#17316 closed defect (bug) (fixed)

Don't 404 on empty post type archives

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

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)

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

Download all attachments as: .zip

Change History (20)

#1 @markmcwilliams
15 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
15 years ago

Yep, my bad.

#3 @scribu
15 years ago

  • Milestone Awaiting Review3.2
  • Version 3.23.1

#4 @scribu
15 years ago

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

#5 follow-up: @jfarthing84
15 years ago

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

@scribu
15 years ago

check only get_queried_object()

#6 @dalesaurus
15 years ago

  • Cc dale.liszka@… added

#7 in reply to: ↑ 5 @nacin
15 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
15 years ago

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

#9 @ryan
15 years ago

  • Milestone 3.2Future Release

Punted per bug scrub.

#10 @nacin
15 years ago

  • Keywords commit added
  • Milestone Future Release3.2

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

#11 @aaroncampbell
15 years ago

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

#12 @johnjamesjacoby
15 years ago

Tested 17316.diff against bbPress plugin, 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.

Version 0, edited 15 years ago by johnjamesjacoby (next)

#13 @nacin
15 years ago

  • Owner set to nacin
  • Resolutionfixed
  • Status newclosed

In [18192]:

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

#14 @gazpachu
15 years ago

  • Keywords needs-testing needs-patch added; has-patch commit removed
  • Resolution fixed
  • Status closedreopened
  • Version 3.13.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
15 years ago

  • Version 3.2.13.1

Please do not change the version number. It's there to track when the bug was introduced/reported.

#16 @scribu
15 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
15 years ago

  • Resolutionfixed
  • Status reopenedclosed

I don't see a bug here.

If there is one, open a new ticket.

Note: See TracTickets for help on using tickets.