Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#35365 closed defect (bug) (duplicate)

Pagination is empty since wp 4.4.1

Reported by: backups's profile BackuPs Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.4.1
Component: Permalinks Keywords:
Focuses: Cc:

Description

Hi

since wp 4.4.1 get_query_var('page') or get_query_var('paged') returns 0 when permalinks are set to /%category%/%postname%

in a static homepage. It works fine with the static homepage.

It also works fine in wordpress 4.4 and below

$paged will return zero. Please Fix

<?php
                global $wp_version;
                if((is_front_page() || is_home() ) && version_compare($wp_version, "3.1", '>=')){//fix wordpress 3.1 paged query 
                        $paged = (get_query_var('paged')) ?get_query_var('paged') : ((get_query_var('page')) ? get_query_var('page') : 1);
                }else{
                        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
                }
                $query['paged'] = $paged;
        }

Change History (6)

#1 @dd32
9 years ago

Hi @BackuPs
Would you be able to confirm if #35344 is related? Do either of the patches on that ticket fix the issue you're seeing?

#2 @BackuPs
9 years ago

Correction.

Note : this only happens on the static front page !! In the none static homepage it works fine.

Last edited 9 years ago by BackuPs (previous) (diff)

#3 @BackuPs
9 years ago

@dd32 that is Exactly the same problem as in #35344

#4 @dd32
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #35344.

Thanks for confirming @BackuPs

I'm going to mark this as a duplicate.

#5 follow-up: @BackuPs
9 years ago

Hi

Thank you for fixing this. I can confirm changing the wp-includes/canonical.php lines 264-270 from this

<?php
                // Post Paging
                if ( is_singular() && ! is_front_page() && get_query_var('page') ) {
                        if ( !$redirect_url )
                                $redirect_url = get_permalink( get_queried_object_id() );
                        $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' );
                        $redirect['query'] = remove_query_arg( 'page', $redirect['query'] );
                }

to

<?php
          // Post Paging 
                if ( is_singular() && get_query_var('page') && ( !is_front_page() || ( isset($wp_query->queried_object) && 'page' == get_option('show_on_front') && $wp_query->queried_object->ID == get_option('page_on_front') ) ) ) { 
                                if ( !$redirect_url ) 
                                                $redirect_url = get_permalink( get_queried_object_id() ); 
                                $page = get_query_var( 'page' ); 
                                if ( is_front_page() ) { 
                                                $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( "$wp_rewrite->pagination_base/$page", 'paged' ); 
                                } else { 
                                                $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( $page, 'single_paged' ); 
                                } 
                                $redirect['query'] = remove_query_arg( 'page', $redirect['query'] ); 
                } 

fixes the issue.

I guess this will be part of the next update?

#6 in reply to: ↑ 5 @francisperron
9 years ago

Replying to BackuPs:

Hi

Thank you for fixing this. I can confirm changing the wp-includes/canonical.php lines 264-270 from this

<?php
                // Post Paging
                if ( is_singular() && ! is_front_page() && get_query_var('page') ) {
                        if ( !$redirect_url )
                                $redirect_url = get_permalink( get_queried_object_id() );
                        $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' );
                        $redirect['query'] = remove_query_arg( 'page', $redirect['query'] );
                }

to

<?php
          // Post Paging 
                if ( is_singular() && get_query_var('page') && ( !is_front_page() || ( isset($wp_query->queried_object) && 'page' == get_option('show_on_front') && $wp_query->queried_object->ID == get_option('page_on_front') ) ) ) { 
                                if ( !$redirect_url ) 
                                                $redirect_url = get_permalink( get_queried_object_id() ); 
                                $page = get_query_var( 'page' ); 
                                if ( is_front_page() ) { 
                                                $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( "$wp_rewrite->pagination_base/$page", 'paged' ); 
                                } else { 
                                                $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( $page, 'single_paged' ); 
                                } 
                                $redirect['query'] = remove_query_arg( 'page', $redirect['query'] ); 
                } 

fixes the issue.

I guess this will be part of the next update?

Thank you so much, it work! It must be in the next WP update!

Note: See TracTickets for help on using tickets.