Make WordPress Core

Opened 8 years ago

Last modified 13 months ago

#37251 new defect (bug)

Not return 404 on front-page with option page and url `/page/2`

Reported by: sheo13666q's profile sheo13666q Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.5.3
Component: Query Keywords:
Focuses: Cc:


If i setup page on front-page(Go Settings->Reading->Set show on front static page and choose own page->Save). Then go to front page on my site (example http://my-domain/) i see page, which setted before. But if i try open http://my-domain/page/2, http://my-domain/page/3 and etc, i get always front-page, except i am wait 404 error. After debug i found solution (line 1777 in query.php):

if ( $this->is_home && 'page' == get_option('show_on_front') && get_option('page_on_front') && !$this->is_paged) {
            $_query = wp_parse_args($this->query);
            // pagename can be set and empty depending on matched rewrite rules. Ignore an empty pagename.
            if ( isset($_query['pagename']) && '' == $_query['pagename'] )

            unset( $_query['embed'] );

            if ( empty($_query) || !array_diff( array_keys($_query), array('preview', 'page', 'paged', 'cpage') ) ) {
                $this->is_page = true;
                $this->is_home = false;
                $qv['page_id'] = get_option('page_on_front');
                // Correct <!--nextpage--> for page_on_front
                if ( !empty($qv['paged']) ) {
                    $qv['page'] = $qv['paged'];

Add && !$this->is_paged check.

Attachments (1)

37251.diff (684 bytes) - added by Presskopp 8 years ago.

Download all attachments as: .zip

Change History (9)

8 years ago

#1 @Presskopp
8 years ago

  • Keywords has-patch added

seems legit to me, patch made

This ticket was mentioned in Slack in #core by presskopp. View the logs.

8 years ago

#3 @Presskopp
8 years ago

  • Keywords needs-unit-tests added

This ticket was mentioned in Slack in #core by presskopp. View the logs.

7 years ago

#5 @desrosj
7 years ago

Hey @Presskopp!

So if your homepage is set to display a static page on front, what content would you expect to see on page/2, page/3, etc.? If it is a single page then there would not be any content to list past the first "page".

At first glance, it makes sense to me that those pages return 404s because there is not paginated content for that page.

#6 @d4z_c0nf
7 years ago

Have you tried the page with a paginated page? (using the <!--nextpage--> tag)
That patch, in this case, brings me to the blog page2.

#7 @Presskopp
7 years ago

  • Keywords has-patch needs-unit-tests removed

When I made the patch things seemed to be different.

#8 @Presskopp
13 months ago

The relevant code is to find in class-wp-query.php, no more in query.php.

If we add !$this->is_paged it will work out well for a non paged homepage. But no more for a paged one. Also the block editor doesn't use <!--nextpage--> but has it's own breaking page block which creates something like

<!-- wp:nextpage -->
<!-- /wp:nextpage -->
Note: See TracTickets for help on using tickets.