-
is it possible to remove only canonical tag from specific pages.
when i create paginated pages my theme (Newspaper by TagDiv) also generate canonical tag.

-
i want my page to be indexed
Hello,
Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.
The 1st canonical tag you are seeing is not being generated by Rank Math. This is likely being added by one of your plugins or active theme.
To determine that, you can follow the steps in this Health Check plugin article.
Also, Rank Math automatically adds a canonical page if the page is set to index.
To remove the canonical tag from the specific page, you need to put the below code inside your themes function.php file.
/** * Allow changing of the canonical URL. * * @param string $canonical The canonical URL. */ add_filter( 'rank_math/frontend/canonical', function( $canonical ) { //change the post id 123 with yours if(is_single ($post = '123') ){ return ''; } return $canonical; });And here’s a link to how to use a filter on your site:
https://rankmath.com/kb/filters-hooks-api-developer/#adding-filters-and-hooks-in-rank-math-phpI hope that helps.
Thank you, and please don’t hesitate to contact us anytime if you need further assistance with anything else.
I came to know by heath check-up is that my plugin who is responsible for theme template is creating “canonical tag”.
that method you suggested to remove canonical tag by rank math is not working
i added your snippet into my theme’s function.php file. but it did not work. so i created rank-math.php file inside my theme’s folder and added that filter to remove canonical tag but unfortunately this didn’t work too. (I did replaced 123 with my post id)that plugin comes with theme so i contacted theme support. they said “you should use yoast Because our theme is compatible with that plugin.
of course i cleared my cache
Hello,
Please remove the code provided by my colleague and try the code given below:
add_filter( 'rank_math/frontend/canonical', function( $canonical ) { if(is_paged () ){ return ''; } return $canonical; });This will remove the canonical tag from the paginated pages.
Hope this helps. Let us know if you need any further assistance.
thanks for response, 😊
but code is not working 😢Hello,
We might need to take a closer look at the settings. Please edit the first post on this ticket and include your WordPress logins in the designated Sensitive Data section.
Please do take a complete backup of your website before sharing the information with us.
It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:
https://wordpress.org/plugins/temporary-login-without-password/
You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):
https://wordpress.org/plugins/wp-security-audit-log/
We really look forward to helping you.
I really appreciate your hard work guys. 👏 but now i decided to delete that page. 😎
don’t worry i am still gonna use your best seo product.
by the way i have given positive review with five star rating.
keep doing hard work guys.Hello,
As you’ve deleted the page, we’re unable to troubleshoot this.
However, could you confirm if we can close this ticket?
Also, if there’s anything else that we can assist you with, please let us know.
Thank 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.
The ticket ‘Canonical tag’ is closed to new replies.