fix RankMath for Better AMP plugin (Canonical Url does not change…)

#69300
  • Resolved Pro Carmanuals
    Rank Math free

    https://support.rankmath.com/ticket/canonical-url-does-not-change

    I was denied a solution to my question.
    I had to make changes to the code myself.
    Hope this helps someone.

    add_action( 'rank_math/frontend/canonical', function( $url ) {
    	$custom_url = RankMath\Post::get_meta( 'canonical_url', get_the_ID() );
    	if ( $custom_url ) {
    		return $custom_url;
    	}
    	return better_amp_guess_none_amp_url();;
    });

    What problems are solved:
    – correct canonical links for amp pages
    – correct canonical links for non amp pages
    – the ability to change canonical links

    • This topic was modified 4 years, 5 months ago by Alberto.
    • This topic was modified 4 years, 5 months ago by Pro Carmanuals.
Viewing 1 replies (of 1 total)
  • Alberto
    Rank Math business

    Hello,

    Thank you for contacting Rank Math today.

    I am sorry we were not able to provide a solution for that, I think it was due to that plugin not being accepted anymore in the WordPress repository.

    But I wanted to thank you for sharing the code you made to fix it, since I am sure it will be really helpful for a lot of people.

    Looking forward to helping you. Thank you.

    ​​​​​​

Viewing 1 replies (of 1 total)

The ticket ‘fix RankMath for Better AMP plugin (Canonical Url does not change…)’ is closed to new replies.