wrong canonical link for pagination

[ad_1]

Hello @thegulshankumar,

Thank you for contacting Rank Math support.

Rank Math adds a self-referencing canonical URL by default for your paginated pages if they are set to index.

However, if it is not working on your site, then you can try the following filter to force the self-referencing canonical URL of your blog pagination:
add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
global $wp;
$current_slug = home_url( $wp->request );
if ( is_paged()) {
$canonical = $current_slug . '/';
}
return $canonical;
});

And here’s a guide on how you can add a filter to your website:
https://rankmath.com/kb/filters-hooks-api-developer/

Hope that helps.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer