Showing incorrect canonical URL with better amp Plugin

#167540
  • Resolved Amanda Blain
    Rank Math free

    Hi there,

    I am currently using the discontinued Better Amp Plugin for AMP. Someday I will upgrade but for now i’ve customized it to work for me.

    The only issue is Rank SEO has some code left for Better AMP /includes/frontend/class-head.php

    Line 45 –
    remove_action( ‘better-amp/template/head’, ‘better_amp_print_rel_canonical’ );

    This removed the Canonical URL created by Better AMP.

    Line 147 –
    if ( Helper::is_amp_active() ) {
    Does NOT detect an AMP page

    Line 216
    – echo ‘<link rel=”canonical” href=”‘ . esc_url( $canonical, null, ‘other’ ) . ‘” />’ . “\n”;

    Shows the incorrect URL on all amp pages –
    <link rel=”canonical” href=”https://www.domain.com/blogpost/amp/”&gt; ( with incorrect /amp/ at end )

    I can manually comment line 46 and 216 out and better amp will display correct url <link rel=”canonical” href=”https://www.domain.com/blogpost/”&gt; once again, but obviously this breaks with every update.

    Can you please offer a suggestion for a permanent fix?

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

    Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for the delay and for any inconvenience this issue may have caused you.

    Could you please confirm if you’re using the Better AMP by Better Studio plugin for your website’s AMP? If so, it seems that the plugin has been banned from WordPress due to policy violations.

    Thank you, and looking forward to your update.

    Yes that plugin.

    I’m not sure which WordPress guidelines were violated but regardless you have partial code in rank SEO that still impacts better amp as I pointed out above and my question remains…

    How can I get the proper url showing?

    Hello,

    Thank you for following up.

    May I know if you have already tried this filter to have the correct canonical links for your amp pages using Better AMP?

    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();;
    });

    If the issue still persists, we can take a closer look at your settings. Please edit the first post on this ticket and include your WordPress & FTP logins in the designated Sensitive Data section.
    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/

    Thank you, and we really look forward to helping you.

    Much Appreciated.. Your included code in theme function.php file correctly fixes the issue with incorrect amp url and better amp plugin.

    I have left feedback for the plugin and thank you for rapid response.

    Anas
    Rank Math business

    Hello,

    We are super happy that your issue is resolved.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

Viewing 5 replies - 1 through 5 (of 5 total)

The ticket ‘Showing incorrect canonical URL with better amp Plugin’ is closed to new replies.