Wordpress Disable Plugin on Specific Pages/Posts

后端 未结 5 1098
醉话见心
醉话见心 2020-12-13 19:28

Does anyone know a really effective method for disabling a plugin (that is active) on a specific page? There are some plugins that are not really needed in some pages of the

5条回答
  •  萌比男神i
    2020-12-13 20:28

    First check, if the plugin you want to remove doesn't have an option menu where you set pages to exclude.

    Second is, look for your plugin action hooks for ex:

    add_action('wp_head', 'easy_fancybox', 999);
    

    This is an example from easy fancybox plugin that hooks to wordpress header. To remove it, I placed this function in your functions.php and before any instance of wp_head(); is called:

    function remove_easy_fancybox() {
    
         remove_action('wp_head', 'easy_fancybox_enqueue_styles');
         remove_action('wp_head', 'easy_fancybox_enqueue_scripts');
         remove_action('wp_head', 'easy_fancybox');
    
         wp_dequeue_script( 'jquery.fancybox' );
         wp_dequeue_script( 'jquery.easing' );
         wp_dequeue_script( 'jquery.mousewheel' );
         wp_dequeue_script( 'jquery.metadata' );
    }
    
    add_action('wp_head', 'remove_easy_fancybox', 1);
    

提交回复
热议问题