Hello,
Thank you for contacting Rank Math today.
You can use the following filter to change the canonical url:
/**
* 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.
Hello,
I have updated the sensitive data as requested. Can you please check further?
Thank you.
Hi sory but not work for me.
for example yoast seo i was using this code:
function return_canon () {
$canon_page = get_pagenum_link(1);
return $canon_page;
}
function canon_paged() {
if (is_paged()) {
add_filter( 'wpseo_canonical', 'return_canon' );
}
}
add_filter('wpseo_head','canon_paged');
So i want only one URL for caninoal url on category url’s page/2/ page/3/… category link.
sitename.com/city/page/2/ in this page caninoal url must be: “sitename.com/city”
-
This reply was modified 4 years, 7 months ago by frednl.
-
This reply was modified 4 years, 7 months ago by frednl.
Hi Firat,
That is not the recommended way of doing things. The canonical on paginated series must be the current page in the series. Otherwise, you might as well noindex your paginated series (that option is provided by the way).
http://www.thesempost.com/google-recommends-self-referencing-canonicals/
Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
thank you for explain, i dont want my pagination index.. for category pages and sitename.com/page/2 sitename.com/page/3/ what i should do?
because im using static page at home, i dont have pagination homepage. And i want give power my category (default url: sitename/category/city like this)
what you recommended for this? thank you…
Hi,
I would recommend going to WordPress Dashboard > Rank Math > Titles & Meta > Misc Pages
Enable the Noindex Paginated Pages
option.
Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
Hi Team,
How do I set self canonicals on paginated pages using the same code on functions.php?
Current Scenario:
/page/2 – canonical to main page
Expected Scenario:
/page/2 having self canonical
Hi Suhas,
You can use this filter to change canonical URLs per your preference:
https://rankmath.com/kb/filters-hooks-api-developer/#change-canonical-url
Please note that we do not offer support for customizations that are not part of the plugin. If you are note familiar with coding, you can consult a coder to customize the filter for your situation. Do note that we neither support this type of edit and neither do we recommend doing this having provided the reason above already.
If you need help with anything else, please open a new support ticket here so we can help.
We are always here for assistance.