• Hello all,
    I updates WP 4.4.1. But error permalink page number homepage:
    https://www.mysite.com/page/2 , https://www.mysite.com/page/3 … always redirect to https://www.mysite.com/

    Url : https://www.mysite.com/?page=2 … worked
    Please help me. Thanks you!

    Code show page number homepage:
    <?php if ($pagination == 'on' && $pagination_type == '') { mom_pagination($query->max_num_pages); } ?>
    and pagination.php theme:

    <?php
    // Depend On : https://www.kriesi.at/archives/how-to-build-a-wordpress-post-pagination-without-plugin
    function mom_pagination($pages = '', $range = 3)
    {
    
           global $wp_query;
            if ( get_query_var('paged') ) { $paged = get_query_var('paged'); }
    elseif ( get_query_var('page') ) { $paged = get_query_var('page'); }
    else { $paged = 1; }
    
         if (mom_option('pagi_type') == false) {
         $showitems = ($range * 2)+1;
    
         if(empty($paged)) $paged = 1;
    
         if($pages == '' && $pages != 0)
         {
             global $wp_query;
             $pages = $wp_query->max_num_pages;
             if(!$pages)
             {
                 $pages = 1;
             }
         }
    
         if(1 != $pages)
         {
             echo "<div class='pagination'>";
             if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>&laquo;</a>";
             if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>&lsaquo;</a>";
    
             for ($i=1; $i <= $pages; $i++)
             {
                 if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
                 {
                     echo ($paged == $i)? "<span class='current'>".$i."</span>":"<a href='".get_pagenum_link($i)."' class='inactive' >".$i."</a>";
                 }
             }
    
             if ($paged < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($paged + 1)."'>&rsaquo;</a>";
             if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>&raquo;</a>";
             echo "</div>\n";
         }
         } else {
    $big = 999999999; // need an unlikely integer
       echo "<div class='pagination'>";
    echo paginate_links( array(
        'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
        'format' => '?paged=%#%',
        'current' => max( 1, $paged ),
        'total' => $pages
    ) );
             echo "</div>\n";
         }
    
    }

Viewing 12 replies - 1 through 12 (of 12 total)
  • Same for me ??

    try resetting your permalink structure from settings->permalink.

    Thread Starter Mr Williams

    (@ngopthanh)

    i try resetting permalink , do not work ??

    have you tried switching to default wp theme ?

    Page number works only with default(Plain) permalink structure. all other structures redirect to home page

    Same for me, anyone has a temporary fix?

    I have the same issue with my sites pagination after the 4.4.1 upgrade. Tried with default theme and others using “Post name” without success.

    What happsn is that it goes back to the root (www.domain.com) instead of https://www.domain.com/page/2

    .htaccess looks ok.

    I have found a temporary fix:
    overwrite the file: wp-includes/query.php with the 4.4 version

    I can confirm this fix!

    Thread Starter Mr Williams

    (@ngopthanh)

    its an issue with wordpress since 4.4.1
    how to fix:

    changing the wp-includes/canonical.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

    // 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'] );
    }

    The fix by ngopthanh is better than mine because overwriting the file: wp-includes/query.php causes a wrong canoinical url in the paged pages.

    The problem is not 100% solved

    I have noticed that with both modifications remain errors in link rel=”canonical” and link rel=’shortlink’

    canonical: mysite.com/NUMBER/ instead of mysite/page/NUMBER/
    This causes a lot of not found errors in Google Serch Console!!!

    shortlink: mysite.com insted of mysite.com/?page=NUMBER

    Any temp solution?

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Error permalink page number homepage!’ is closed to new replies.