Make WordPress Core

Opened 13 months ago

Closed 9 months ago

Last modified 9 months ago

#23826 closed defect (bug) (wontfix)

Funky conditional tags for posts archive

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


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

comment:1 follow-up: alexvorn213 months ago

  • Keywords close added

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

Version 0, edited 13 months ago by alexvorn2 (next)

comment:2 in reply to: ↑ 1 ericlewis13 months 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.

comment:3 follow-up: nacin13 months 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.

comment:4 nacin9 months ago

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

comment:5 in reply to: ↑ 3 ericlewis9 months 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.

comment:6 ericlewis9 months ago

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

comment:7 helen9 months ago

  • Keywords 2nd-opinion removed
  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.