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 16 replies (of 16 total)
  • Hello,

    I checked and figured out that the canonical you are seeing on your posts are not coming from our plugin and that’s why the filter is not able to change it. Since your site is set as Noindex in the Reading settings of WordPress, our plugin will not add the canonical URL.

    The canonical URL is being added by the WP RSS Aggregator – Feed to Post plugin. If you disable that plugin, you can check that the canonical tag will be removed. You should get in touch with the support of the plugin and ask them to remove the canonical tag. Once done, the filter will add the correct URL once you set your site as Index.

    Hope that helps. Let us know if you need any other assistance.

Viewing 16 replies (of 16 total)

You must be logged in to reply to this ticket.