Skip to content

Instantly share code, notes, and snippets.

@spasicm
Created October 13, 2021 10:14
Show Gist options
  • Save spasicm/d4e9139ff6c625d1aca3b26522de00d6 to your computer and use it in GitHub Desktop.
Save spasicm/d4e9139ff6c625d1aca3b26522de00d6 to your computer and use it in GitHub Desktop.
WordPress disable plugin on specific page
<?php
// To make this plugin to work, you must put this file in "wp-content/mu-plugins" directory.
// You can read mora about WordPress MU (Must Use) Plugins on the link -> https://wordpress.org/support/article/must-use-plugins/
add_filter( 'option_active_plugins', 'disable_specific_plugin' );
function disable_specific_plugin($plugins){
if( $_SERVER['REQUEST_URI'] == '/some-url' ) { // Change "/some-url" with url of page you want to disable plugin (without domain).
$key = array_search( 'some-plugin/some-plugin.php' , $plugins ); // Change "some-plugin/some-plugin.php" with the directory name and main .php file name of the plugin you want to disable.
if ( false !== $key ) unset( $plugins[$key] );
}
return $plugins;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment