• We have identified that the positioning of the amphtml canonical link in the <head> needs to be as high as possible in order to be picked faster.

    Yoast hooks unfortunately push it quite down so i decided to manually add the amphtml tag in the head area and wanted to remove your code.

    I have tried the following

    add_filter( 'amp_frontend_show_canonical', '__return_false' );

    and

    remove_action( 'wp_head', 'amp_frontend_add_canonical' );

    inside functions.php but nothing seems to remove the link.

    Any insights on this?

Viewing 4 replies - 1 through 4 (of 4 total)
  • We’re having a similar issue where even if we flag a post to be skipped for AMP, it’s still getting the amphtml link in the header.

    Perhaps this code isn’t working as well in the latest version?

    Plugin Contributor ampforwp

    (@ampforwp)

    Hi @froutsis,

    May I know where you want to show the amphtml canonical link? And also where you apply this filter “amp_frontend_show_canonical”? let me know so that I can understand your use-case scenario.

    Thank you

    Thread Starter Fotis Routsis

    (@froutsis)

    I have tried both

    add_filter( ‘amp_frontend_show_canonical’, ‘__return_false’ );
    remove_action( ‘wp_head’, ‘amp_frontend_add_canonical’ );

    in the functions.php of my theme.

    The canonical link I print it myself in the <head> directly (inside the header.php) but i want to remove the link that is being print by the plugin.

    I want the canonical rel to be one of the first things in the head area.

    Plugin Contributor ampforwp

    (@ampforwp)

    Hi @froutsis,

    Please try the below code:

    // amphtml remove from the plugin
    add_action( 'wp', 'ampforwp_remove_endpoint_actions',11 );
    function ampforwp_remove_endpoint_actions() {
    	remove_action( 'wp_head', 'ampforwp_home_archive_rel_canonical', 1 );
    }

    And let me know whether it is resolved or not.

    Hope it helps.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Remove the amphtml canonical in non amp pages’ is closed to new replies.