Add rel=canonical when URL isn’t available to modify in WordPress

#464581
  • Resolved benalarie
    Rank Math free

    Hi,

    I have duplicate content with two different URLs. The duplication of the content occurred by accident when I modified the url pagination (category) after the post was published. Now, I have the original post B indexed and post A indexed (post A = the up-to-date post that I can access through WordPress).

    Your Rankmath tool helped me add a rel=canonical tag to post A. However, I also want to add a rel=canonical tag to post B, pointing to post A.

    How do I do that if I can’t access the URL through the WordPress > Posts section (its not there because I updated it)?

    Does your tool have the ability to do this?

    Thanks in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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.

    Could you please share the affected/duplicate URL so we can check as well? You can add it in the sensitive data section

    Sensitive Data Section

    It is completely secure, and only our support staff has access to that section.

    Meanwhile, you can use and modify this filter on your site to set 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;
    });

    The filter should be added to your active theme’s functions.php file. Here’s another way to apply the filter using the rankmath.php file:
    https://rankmath.com/kb/filters-hooks-api-developer/#adding-filters-and-hooks-in-rank-math-php

    Let us know how this goes.

    Thank you.

    Also, my RankMath plugin is still not updating. Can you tell me why?

    https://thecontrarycanary.com/investing/gold-ira/best-gold-ira-company

    https://thecontrarycanary.com/investing/gold-ira/how-to-invest-in-gold-ira/

    https://thecontrarycanary.com/investing/how-to-invest-in-gold-ira

    https://thecontrarycanary.com/investing/augusta-precious-metals-review

    These are the non-canonical URLs. I also put a 301 redirect on them but my traffic on the current canonical URLs is still taking a massive hit. I think it’s because I can’t specify the canonical URLs on the URLs from above.

    As you can imagine – the URLs above doesn’t exist on the backend of my WordPress account (because I updated them). However, they do exist on the internet and can be crawled. So how do I use RankMath to add a canonical tag to them so they start ranking better in Google?

    Thanks,
    Ben

    Hello,

    You don’t have to add canonical to the URLs you shared since they are already been redirected.

    If those URLs are still indexed on the search engine, the best you can do is to allow Google to recrawl your website and all the traffic and ranking from that old URL will be transferred to the new one. Kindly give it some time for Google to recrawl the URLs to see if the error goes away in the Google Search Console.

    As for the issue with your plugin not updating, can you please check if there are any error messages shown when attempting to update?

    To update the plugin automatically, enable auto-updates by going to WordPress dashboard > Rank Math > Status & Tools > Version Control > Auto-Update: https://rankmath.com/kb/version-control/#auto-update
    auto update

    Looking forward to helping 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.

Viewing 4 replies - 1 through 4 (of 4 total)

The ticket ‘Add rel=canonical when URL isn’t available to modify in WordPress’ is closed to new replies.