Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#10822 closed defect (bug) (invalid)

Post page is 404 when no post found on static page for homepage

Reported by: v.guerard Owned by: ryan
Milestone: Priority: normal
Severity: normal Version: 2.8
Component: Query Keywords: is_posts_page
Focuses: Cc:


On front page configuration, I specify 2 static pages, one for homepage (ex: page1), and another for posts page (ex: page2).

If I have no post, page2 is like a 404 page.

The $wp_query is well parsed, but on handle_404() call, no test on $wp_query->is_posts_page flag is available (like category or tag query).
The handle_404 test change the $wp_query setting and it's not possible to know if we are in posts_page or not(is_404 = true and is_posts_page = false).

is_post_page is not used a lot in the source code, I haven't found an is_posts_page() global function.
So we can had it :

function is_posts_page() {

global $wp_query;

return ($wp_query->is_posts_page);


and in handle_404 of wp-includes/classes.php (line 464 on 2.8) change the line

if ( ( is_tag()
is_category() is_author() ) && $wp_query->get_queried_object() ) {


if ( ( is_tag()
is_category() is_author() is_posts_page()) && $wp_query->get_queried_object() ) {

It's seem that the problem is only available with this configuration. No problem if I use same homepage and post_page.

Change History (2)

#1 @davesgonebananas
12 years ago

You could be searching for the function is_home() here.
Also, when there are no posts found for the blog index WP doesn't issue a 404, it calls the theme's index.php in which have_posts() will return false. Therefore, are you sure the 404 you are seeing is not a result of your theme's index.php.

#2 @nacin
12 years ago

  • Milestone Unassigned deleted
  • Resolution set to invalid
  • Status changed from new to closed

Seems invalid. Re-open with a better explanation.

Note: See TracTickets for help on using tickets.