Opened 2 years ago

Closed 23 months 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: 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)

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

Download all attachments as: .zip

Change History (20)

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

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   jfarthing842 years ago

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

scribu2 years ago

check only get_queried_object()

  • Cc dale.liszka@… added

comment:7 in reply to: ↑ 5   nacin2 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().

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

comment:9   ryan2 years ago

  • Milestone changed from 3.2 to Future Release

Punted per bug scrub.

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

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

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

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 2 years ago by johnjamesjacoby (previous) (diff)
  • 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.

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

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.

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