Skip to content

Instantly share code, notes, and snippets.

@glueckpress
Last active March 5, 2019 21:15
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save glueckpress/cff7475b113b75cb2a426ead6d6190c0 to your computer and use it in GitHub Desktop.
Save glueckpress/cff7475b113b75cb2a426ead6d6190c0 to your computer and use it in GitHub Desktop.
[WordPress][WP Rocket]Disable all WP Rocket functions on AMP pages created by the Automattic AMP plugin.
<?php
/**
* UNTESTED EXAMPLE!
* Please don’t use in production without having tested it before!
* @link http://wordpress.stackexchange.com/a/12165
* @return void
*/
function example__disable_rocket_cache_for_amp_pages() {
if ( ! defined( 'AMP_QUERY_VAR' ) )
return;
if ( ! function_exists( 'is_amp_endpoint' ) )
return;
if ( is_amp_endpoint() )
deactivate_plugins( '/wp-rocket/wp-rocket.php', true ); // true => silent deactivation, no deactivation hooks called
}
add_action( 'wp', 'example__disable_rocket_cache_for_amp_pages' );
@sayakshinobu
Copy link

I need to use this. where I have to put it? in the theme functions.php or somewhere else?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment