Opened 2 months ago

Last modified 6 weeks ago

#23826 new defect (bug)

Funky conditional tags for posts archive

Reported by: ericlewis Owned by:
Priority: normal Milestone: Awaiting Review
Component: Query Version: trunk
Severity: normal Keywords:
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 (3)

comment:1 follow-up: ↓ 2   alexvorn22 months 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 2 months ago by alexvorn2 (previous) (diff)

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

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.

Note: See TracTickets for help on using tickets.