Created
September 23, 2020 10:23
-
-
Save pradeep910/3ffc353bf370ac6ffd20f85c4cc0c8c9 to your computer and use it in GitHub Desktop.
AMP error handling example for WordPress
This file contains 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 | |
function amp_wp_org_is_amp() { | |
return function_exists( 'is_amp_endpoint' ) && is_amp_endpoint(); | |
} | |
if ( amp_wp_org_is_amp() ) { | |
// Remove script from AMP pages. | |
wp_dequeue_script( 'script-handle' ); | |
} | |
if ( ! amp_wp_org_is_amp() ) { | |
// Include scripts only on Non-AMP pages. | |
wp_enqueue_script( 'script-handle' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment