Skip to content

Instantly share code, notes, and snippets.

@pradeep910
Created September 23, 2020 10:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pradeep910/3ffc353bf370ac6ffd20f85c4cc0c8c9 to your computer and use it in GitHub Desktop.
Save pradeep910/3ffc353bf370ac6ffd20f85c4cc0c8c9 to your computer and use it in GitHub Desktop.
AMP error handling example for WordPress
<?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