[OFFER ALERT!] This Halloween, Get Any Premium Theme for Just $19 [GET IT NOW]
Jump to content

[Rank Math SEO Plugin] Referenced AMP URL is self-canonical AMP


cbstudiomx
 Share

Recommended Posts

  • Support

Hello,

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

Can you please tell us the AMP plugin you are using on your website?

Also, please make sure you are using the latest version of the plugin.

Looking forward to helping you.


🏁Rank #1 on Google With our WordPress SEO Plugin

Score a 💯on PageSpeed and Dominate Search Rankings.

✏ Editing theme files? Please create a child theme to make your changes update-proof.

Link to comment
Share on other sites

Hello,

We use Better AMP v1.9.10

In the htmp code of the generated post or page, the canonical URL is declared by Rank Math!

I think the rule has to be simple and you have to put it in to a next update: if page si AMP, canonical URL has to be the parent page else, use the actual page.

Referenced AMP URL is self-canonical AMP The canonical page points to a stand-alone AMP. You cannot reference a stand-alone AMP as the AMP version of a page. Learn how to reference an AMP from a non-AMP page.
Link to comment
Share on other sites

  • Support

Hello,

Currently, Rank Math is not fully compatible with Better AMP plugin. I've forwarded this issue to our development team and they will release an update soon addressing this issue.

For not to fix it on your site please add below code to your active theme's funcitons.php file:

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

	return better_amp_rel_canonical_url();
});

Hope that helps. Please let us know if there is anything else.

Thank you.


🏁Rank #1 on Google With our WordPress SEO Plugin.

Score a 💯on PageSpeed and Dominate Search Rankings.

✏ Editing theme files? Please create a child theme to make your changes update-proof.

Link to comment
Share on other sites

  • 1 month later...

That code did not work for me, but I search in better amp plugin for a "better" function to call and I change your code, and this work for me:

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

 

Link to comment
Share on other sites

  • Support

Hello,

Glad you got that working. We are going to get in touch with the Better AMP team soon to ask them to make their plugin compatible with Rank Math. Once that plugin is compatible you won't be needing this code.

In the meantime, if there is anything else please let us know.

Thank you.

 


🏁Rank #1 on Google With our WordPress SEO Plugin.

Score a 💯on PageSpeed and Dominate Search Rankings.

✏ Editing theme files? Please create a child theme to make your changes update-proof.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...