Rank Math creating wrong canonicals

#98568
  • Resolved Jurre S.I.
    Rank Math free

    I use RankMath on my website combined with the CoinPress plugin. But for my coinpages it creates wrong canonicals.

    Page is: root/cryptocurrency-koersen/bitcoin/
    But the canonical for all pages ends up being: root/cryptocurrency-prices-marketcap/

    It was fixable by making some changes to the PHP. Unfortunately this change has been undone and I can’t find the code anymore.

    Can you please help me to fix it?

Viewing 1 replies (of 1 total)
  • Alberto
    Rank Math business

    Hello,

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    I am not sure what is the exact code you were using but you can use the following filter to modify the canonical based on whatever you want:

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

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

Viewing 1 replies (of 1 total)

The ticket ‘Rank Math creating wrong canonicals’ is closed to new replies.