html link tag rel=canonical

#452193
  • Resolved Shahwal SG
    Rank Math free

    hello sir,

    I want to change the URL or link tag rel=canonical. I have large number of posts on my site. I want to change this from filter. I have tried with these filters but these are only change the value of meta og:url not link tag value please let me know how I can change this without editing one by one post Thanks

    /**
    * Allow changing of the canonical URL.
    *
    * @param string $canonical The canonical URL.
    */
    add_filter( ‘rank_math/frontend/canonical’, function( $canonical ) {
    return $canonical;
    });

    /**
    * Allows the output of the canonical URL as OpenGraph URL, consolidating likes and shares.
    *
    * @link https://developers.facebook.com/docs/reference/opengraph/object-type/article/
    * @param $url Canonical URL
    */
    add_filter( ‘rank_math/opengraph/url’, function( $url ) {
    return $url;
    });

Viewing 15 replies - 1 through 15 (of 16 total)
  • Hello,

    Thank you for contacting Rank Math today.

    The first filter of those two is used to change the canonical tag within our plugin, so if you pass a URL to the $canonical variable in that filter it will output that value.

    ​​​​​​Don’t hesitate to get in touch if you have any other questions.

    i have tried with this way but it’s not working for <link rel="canonical" href="" />
    this is only working for <meta property="og:url" content="" />

    Hello,

    Could you please share the filter you have created so we can check? You can paste the code into the sensitive data section.

    Sensitive Data Section

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

    Looking forward to helping you.

    Thank you.

    here is the code please check

    add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
        global $post;
        if (is_single()) {
            $canonical = get_the_permalink($post->ID);
        }
        return $canonical;
    });

    Hello,

    I’ve tested the filter you’ve shared with us from my end and it seems to be working perfectly fine.

    Can you please try clearing your caches from your site and try again to see if it works for you or not?

    If the issue still persists, then we might need to take a closer look at the settings. Please edit the first post on this ticket and include your WordPress & FTP logins in the designated Sensitive Data section.

    Please do take a complete backup of your website before sharing the information with us.

    Sensitive Data Section

    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.

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    I cannot share the FTP details FTP only can access by the key you can check this from Appearance Edit Theme File check functions.php Line No 448 to 461 there is the code I have added and check the plugin settings and let me know the issue.

    Thanks

    Hello,

    It seems that you’re currently using the Rank Math Business plan, but the account you have used to open this ticket is the Rank Math free version.

    Can you please search and forward a receipt from FastSpring.com so we can locate your account and verify it?

    As for your issue, I can see that most of the page is cached, Rank Math isn’t updated and Yoast configurations still have an effect on your site. Please try removing caches from your site(as you have used WP Rocket earlier), update the Rank Math SEO plugin, and regarding Yoast, you can try contacting Yoast support to learn why it still affecting your site even after you’ve deactivated their plugin.

    Looking forward to helping you.

    Thank you.

    I have shared the receipt on email please check and resolve this issue asap.

    thanks

    I have added invoice id in Sensitive Data please check

    Nigel
    Rank Math business

    Hello,

    I checked your site and noticed that the meta-robots tag is set to noindex and this is preventing the implementation of the canonical. The canonical filter should work on the live website which will be set to index.

    Hope that helps. Please let us know if you have questions.

    Hello,

    I have remove the meta robots no index but still it won’t worked for me please check again.

    Thanks

    Hello,

    I can check that the canonical tag is now being added to your site:

    Please clear the cache of your site & browser and check again.

    Let us know if you need any other assistance.

    Why you are checking the page as I cleared mentioned in my code I want to update for post pages and this is not fixed yet pages are fine.
    please check the post pages

    You haven’t checked my code what I need to be done and where I need to get it done please check this code I have updated rel=canonical on for the post pages

    add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
        global $post;
        if (is_single()) {
            $canonical = get_the_permalink($post->ID);
        }
        return $canonical;
    });
Viewing 15 replies - 1 through 15 (of 16 total)

You must be logged in to reply to this ticket.