How to solve a conflict between a plugin and a theme?

If the theme was coded using Theme Development Standards, then you can use the function wp_deregister_script to remove conflicting scripts from the page where the slider is being used.


[update]
The original solution (at the bottom) worked in a specific plugin situation (with WP Touch).
I think this is the proper one:

add_action( 'wp_enqueue_scripts', 'wpse_77772_remove_theme_enqueues', 11 );

function wpse_77772_remove_theme_enqueues()
{
    if( is_front_page() || is_home() ) 
    {
        wp_dequeue_script('hatch_pro_fancybox');
        // etc
    }
}

[first version]

For example, in the following snippet I’m removing all the scripts and style of the plugin Alo Easy Mail if the site is being viewed in a mobile device, check comments for your use case.

Put it at the end of the theme’s functions.php file (or child theme’s).

add_action( 'wp_head', 'wpse_77772_remove_plugin_scripts', 1 );

/**
 * You'd probably want to use
 * if( is_front_page() || is_home() ) 
 *
 * see: http://wordpress.stackexchange.com/q/30385/12615
 */
function wpse_77772_remove_plugin_scripts()
{
    if( wp_is_mobile() ) {
        remove_action('wp_head', 'add_css');
        wp_deregister_script('jqplot');
        wp_deregister_script('bar');
        wp_deregister_script('cax');
        wp_deregister_script('pol');
        wp_deregister_script('fun');
        wp_deregister_script('pie');
        wp_deregister_script('meg');
    }
}

This way, you can remove the conflicting scripts from a specific page, and let them load in the rest.

Search your theme for wp_register_script and grab the handle to use with deregister.

The remove_action works upon all add_action that the theme has.

Leave a Comment