user948319
user948319

Reputation: 356

in my wordpress blog when click on pagination link it redirect to wrong url

i already tried https://wordpress.org/support/topic/clicking-on-page-2-redirects-to-the-home-page

here is my url of pagination which is correct http://studycopter.com/feed/page/2/

but when i click on link then it redirect to http://studycopter.com/page/2/

i check every things like .htaccess file permalink site url base url also deactivate all plugins

but didn't resolve the issue

Please Help me!

Upvotes: 1

Views: 2190

Answers (1)

user948319
user948319

Reputation: 356

The Problem Resolved

the problem occurs due to feed keyworrd by changing /wp-includes/canonical.php

//before the code is

// paging and feeds
if ( get_query_var('paged') || is_feed() || get_query_var('cpage') ) {
    while ( preg_match( "#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", $redirect['path'] ) || preg_match( '#/(comments/?)?(feed/rss|rdf|atom|rss2)(/+)?$#', $redirect['path'] ) || preg_match( "#/{$wp_rewrite->comments_pagination_base}-[0-9]+(/+)?$#", $redirect['path'] ) ) {
        // Strip off paging and feed
        $redirect['path'] = preg_replace("#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", '/', $redirect['path']); // strip off any existing paging
        $redirect['path'] = preg_replace('#/(comments/?)?(feed/rss2?|rdf|atom)(/+|$)#', '/', $redirect['path']); // strip off feed endings
        $redirect['path'] = preg_replace("#/{$wp_rewrite->comments_pagination_base}-[0-9]+?(/+)?$#", '/', $redirect['path']); // strip off any existing comment paging
    }

    //more code

}

//after removing feed

// paging and feeds
if ( get_query_var('paged') || is_feed() || get_query_var('cpage') ) {
    while ( preg_match( "#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", $redirect['path'] ) || preg_match( '#/(comments/?)?(rss|rdf|atom|rss2)(/+)?$#', $redirect['path'] ) || preg_match( "#/{$wp_rewrite->comments_pagination_base}-[0-9]+(/+)?$#", $redirect['path'] ) ) {
        // Strip off paging and feed
        $redirect['path'] = preg_replace("#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", '/', $redirect['path']); // strip off any existing paging
        $redirect['path'] = preg_replace('#/(comments/?)?(rss2?|rdf|atom)(/+|$)#', '/', $redirect['path']); // strip off feed endings
        $redirect['path'] = preg_replace("#/{$wp_rewrite->comments_pagination_base}-[0-9]+?(/+)?$#", '/', $redirect['path']); // strip off any existing comment paging
    }

    //more code

}

Upvotes: 1

Related Questions