-
Hello,
Is there a way to disable the automated tagging set up by Rankmath?
The reason I am asking this is that I’ve identified pages on my website that have 2 different canonical tags in their codes and believe that these canonical tags are set by rank math.
Here is an example: https://www.amadeus-hospitality.com/new-hotsos-offer/ (you would need to inspect code to see there are 2 canonical tags on that page).
-
Hello,
Thank you for contacting Rank Math support, and sorry for any inconvenience that might have been caused due to that.
You’re using Pro version of the plugin but opened this ticket using free account.
Can you please search and forward a receipt from FastSpring.com so we can locate your account and verify it?
It isn’t recommended to have more than one canonical tag on your page. There’s another plugin which is adding canonical tag in the website.
You can also disable the canonical tag of our plugin using the following filter:
add_filter( 'rank_math/frontend/canonical', function( $canonical ) { return false; });Here is how to add a filter to your site: https://rankmath.com/kb/wordpress-hooks-actions-filters/
Hope that helps. Let us know if you need any other assistance.
Thank you
This is great…thanks…but I only want to run this on blog posts from a particular category
Lets call it /syndicate for the category name. Is this possible? My sydication service insert a canonical tag to the original source but I would need to still have this setting for my original content.
Hello,
Yes, that’s possible, please try adding the following filter on your site to remove the canonical generated by Rank Math on a specific category only:
add_filter( 'rank_math/frontend/canonical', function( $canonical ) { $categories = array_map( function ( $category ) { return $category->slug; }, get_the_category() ); if ( in_array( 'category-slug', $categories ) ) { //replace 'category-slug' with your category slug return false; } return $canonical; }, 10, 2);Let us know how it goes. Looking forward to helping you.
Thank you.
Great thanks…works like a charm
I am wondering now if we can detect the source, for example, only execute this script against any URL with outnabootblog.com in the original source
Hello,
In that case, please try adding the following filter replacing the above one to see if that works for you:
add_filter( 'rank_math/frontend/canonical', function( $canonical ) { $categories = array_map( function ( $category ) { return $category->slug; }, get_the_category() ); if ( ( in_array( 'category-slug', $categories ) ) && (home_url() == 'https://outnabootblog.com') ) { //replace 'category-slug' with your category slug. return false; } return $canonical; }, 10, 2);Let us know how it goes. Looking forward to helping you.
Thank you.
Thanks…doesn’t seem to be working.
Here is the source code of the page we are testing on
view-source:https://www.pureit.ca/microsoft-places-the-tool-making-remote-work-more-manageable/
You will see a canonical URL for the website and another for the source. We only want to show the source. This is being pulled by a plugin called “Autoblog”
Hello,
It looks like there’s some sort of misunderstanding.
The URL you’ve shared is of the domain
https://www.pureit.ca/, but above you mentioned the URLoutnabootblog.com.Can you please explain more about the situation? That will help us to provide you accurate code.
Looking forward to hearing back from you.
Thank you.
Hi, we are importing syndicated blogs from outnabootblog.com to pureit.ca. We want the canonical URL not to be pureit.ca for any syndicated blog coming from outnabootblog.com.
The path is
ORGINAL URL – outnabootblog.com
AUTOBLOG plugin on pureit.ca retrieves posts every 24 hours
PUBLISHED on pureit.ca — but we want the canonical to point back to outnabootblog.com, this is what the autoblog plugin does. Rank Math is inserting another canonical reference that we don’t want to have show on this syndicated blogs. But, we do want the rank math canonical reference to show on every other post or page not part of the syndication.
Hello,
Thank you for that additional information.
Upon checking, there’s an additional canonical URL pointed back to outnabootblog.com in the page’s source code.
This filter will remove the canonical from Rank Math where the category is syndicate, which you mentioned is coming from outnabootblog.com:
add_filter( 'rank_math/frontend/canonical', function( $canonical ) { $categories = array_map( function ( $category ) { return $category->slug; }, get_the_category() ); if ( in_array( 'syndicate', $categories ) ) { return false; } return $canonical; }, 10, 2);Hope that helps.
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 ‘remove automated canonical tag’ is closed to new replies.