-
-
Save thegulshankumar/3a38eb2b1d08394a5fbb7faefc8695c2 to your computer and use it in GitHub Desktop.
Remove output of rel=amphtml in official AMP plugin (WordPress)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Callbacks for adding AMP-related things to the main theme | |
/** Using comment syntax at amp/includes/amp-frontend-actions.php file. | |
add_action( 'wp_head', 'amp_frontend_add_canonical' ); | |
function amp_frontend_add_canonical() { | |
if ( false === apply_filters( 'amp_frontend_show_canonical', true ) ) { | |
return; | |
} | |
$amp_url = amp_get_permalink( get_queried_object_id() ); | |
printf( '<link rel="amphtml" href="%s" />', esc_url( $amp_url ) ); | |
} | |
End Comment. **/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: In the official AMP plugin, edit amp/includes/amp-frontend-actions.php file for removing rel=amphtml output from the head of non-amp web page.