WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#17316 closed defect (bug) (fixed)

Don't 404 on empty post type archives

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

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 3 years ago.
17316.diff (729 bytes) - added by markmcwilliams 3 years ago.
17316.patch (702 bytes) - added by scribu 3 years ago.
check only get_queried_object()

Download all attachments as: .zip

Change History (20)

jfarthing843 years ago

comment:1 markmcwilliams3 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? :)

markmcwilliams3 years ago

comment:2 jfarthing843 years ago

Yep, my bad.

comment:3 scribu3 years ago

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

comment:4 scribu3 years ago

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

comment:5 follow-up: jfarthing843 years ago

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

scribu3 years ago

check only get_queried_object()

comment:6 dalesaurus3 years ago

  • Cc dale.liszka@… added

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

comment:8 scribu3 years ago

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

comment:9 ryan3 years ago

  • Milestone changed from 3.2 to Future Release

Punted per bug scrub.

comment:10 nacin3 years ago

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

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

comment:11 aaroncampbell3 years ago

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

comment:12 johnjamesjacoby3 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 3 years ago by johnjamesjacoby (previous) (diff)

comment:13 nacin3 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.

comment:14 gazpachu3 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.

comment:15 SergeyBiryukov3 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.

comment:16 scribu3 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.

comment:17 nacin3 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.