How to set a self-canonical reference to pagination pages

[ad_1]

Hello @reminaizer,

Thank you for contacting the support.

Rank Math adds a self-referencing canonical URL by default, meaning if your paginated page is /page/2/, the canonical URL should be the same.

If it’s not working for you, then you may try adding the following filter to add self-referencing canonical URLs for your paginated blog pages:

add_filter( 'rank_math/frontend/canonical', function( $canonical ) { $current_url="https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; if(false === strpos($current_url, '/page/') || is_single()) return $canonical; $canonical = strtok($current_url, '?'); return $canonical; });

Here is how you can add filters/hooks to your WordPress site:

Let us know how it goes. Looking forward to helping you.

 

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