Hello,
Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.
You can easily customize the canonical URL returned on the paginated pages by using the following filter on your theme’s functions.php file:
/**
* Allow changing of the canonical URL.
*
* @param string $canonical The canonical URL.
*/
add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
return $canonical;
});
Looking forward to helping you. Thank you.
Hi There,
Should something like this work? For some reason it’s not showing on our pages:
/**
* Allow changing of the canonical URL.
*
* @param string $canonical The canonical URL.
*/
add_filter( ‘rank_math/frontend/canonical’, function( $canonical ) {
if ( !is_front_page() && is_home() ) {
global $paged;
if ( get_previous_posts_link() ) { ?>
<link rel=”prev” href=”<?php echo get_pagenum_link( $paged – 1 ); ?>” /><?php
}
if ( get_next_posts_link() ) { ?>
<link rel=”next” href=”<?php echo get_pagenum_link( $paged +1 ); ?>” /><?php
}
}
return $canonical;
});
Thank you!
Further look, this seems to be an elementor page element with pagination. Any thoughts on that? Thank you!
Hi Will,
Please note that Google dropped support for rel=”next” and prev tags quite a while back:
https://searchengineland.com/google-no-longer-supports-relnext-prev-314319
The best option to do for paginated pages is to mark them as noindex
.
Head over to WordPress Dashboard > Rank Math > Titles & Meta > Misc. Pages.`
Scroll down a bit and you will see the Noindex Paginated Pages option.
If you still wish to do it like you mentioned, please wait for someone from our dev. team to get back to you.
Hello,
Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.
If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.
Thank you.