[wp-trac] [WordPress Trac] #37251: Not return 404 on front-page with option page and url `/page/2`

WordPress Trac noreply at wordpress.org
Fri Jul 1 15:31:12 UTC 2016


#37251: Not return 404 on front-page with option page and url `/page/2`
--------------------------+-----------------------------
 Reporter:  sheo13666q    |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Query         |    Version:  4.5.3
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 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`):
 {{{#!php
 <?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['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'];
                     unset($qv['paged']);
                 }
             }
         }
 }}}

 Add `&& !$this->is_paged` check.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/37251>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list