Hello,
Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.
It is usually this way. Pointing the paginated pages to the main page using canonical helps in avoiding duplicate content issues. To change the canonical URL of the dynamically generated paginated pages on your site, you can use the following filter: https://rankmath.com/kb/filters-hooks-api-developer/#change-canonical-url
Looking forward to helping you. Thank you.
I understand that this code still needs to be redone in some way, I could ask for help, how exactly should it look like?
Hello,
You could use the following code:
/**
* Allow changing of the canonical URL.
*
* @param string $canonical The canonical URL.
*/
add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
global $wp;
$current_url = home_url(add_query_arg(array($_GET), $wp->request));
$parsedUrl = parse_url($current_url);
if(isset($url['query'])){
// It has parameters, set that URL as canonical
return $parsedUrl;
}
return $canonical;
});
Looking forward to help 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.