Make WordPress Core

Opened 12 years ago

Closed 11 years ago

Last modified 9 years ago

#23826 closed defect (bug) (wontfix)

Funky conditional tags for posts archive

Reported by: ericlewis's profile ericlewis Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: Query Keywords:
Focuses: Cc:

Description

If a WordPress install is set to "Front page displays ... Your latest post", then some funky conditional tags are set. Of interest here are:

["is_home"]=> bool(true)
Sure, makes sense.

["is_post_type_archive"]=> bool(false)
Erm, what? Isn't this the post type archive for the posts post type?

["is_archive"]=> bool(false)
Isn't this also an archive?

This means is_post_type_archive( 'post' ); doesn't work anywhere.

I also attempted creating a "posts page" for blog posts, and got the same results.

Change History (9)

#1 follow-up: @alexvorn2
12 years ago

  • Keywords close added

is_archive() function is for only tags page (tag.php), categories page (category.php), other taxonomies pages, so
"is_archive" for front page will be always false...

Last edited 12 years ago by alexvorn2 (previous) (diff)

#2 in reply to: ↑ 1 @ericlewis
12 years ago

  • Keywords close removed

Replying to alexvorn2:

is_archive() function is for only tags page (tag.php), categories page (category.php), other taxonomies pages, so
"is_archive" for front page will be always false...

When the front page or another page is a placeholder for a post archives page, it is an archive page shoehorned into a front-page or a single page, and should probably be considered a post type archive, or at least lead to a discussion, because this leads to unexpected functionality of the is_post_type_archive() function.

#3 follow-up: @nacin
12 years ago

is_post_type_archive wasn't originally a flag. It was a piggyback on is_archive. It was certainly understood at the time that is_home basically (I'm simplifying significantly here) a post type archive for posts. And yes, neither is_archive nor is_post_type_archive will be true for them.

There's no post type archive for pages either, as pages cannot be browsed in archive form. So, just think of post type archives as for custom post types only. Over time, functionality that is intrinsic and unique to posts and pages may get abstracted a bit more, which may lead to improvements here.

This is just one of those situations we're going to live with. At some point, maybe a new level of abstraction comes along and we're able to significantly change how query flags work. But this is what we have to work with for now.

#4 @nacin
11 years ago

  • Keywords 2nd-opinion added
  • Version changed from trunk to 3.1

#5 in reply to: ↑ 3 @ericlewis
11 years ago

Replying to nacin:

This is just one of those situations we're going to live with.

Thanks, I agree after reading your response; I suggest #wontfix this.

#6 @ericlewis
11 years ago

  • Resolution set to wontfix
  • Status changed from new to closed

#7 @helen
11 years ago

  • Keywords 2nd-opinion removed
  • Milestone Awaiting Review deleted

#8 @SergeyBiryukov
9 years ago

#32272 was marked as a duplicate.

#9 @Howdy_McGee
9 years ago

#32272 was marked as a duplicate.

Note: See TracTickets for help on using tickets.