WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm currently using a plugin, which includes jquery version 1.6.4 like this:

function thethe_image_slider_head_scripts(){
    wp_deregister_script( 'jquery' );
    wp_register_script( 'jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/  jquery.min.js', false, 'latest');
    wp_enqueue_script( 'jquery' );

    wp_enqueue_script('slider-ui', THETHE_IMAGE_SLIDER_URL.'style/js/thethe-image-slider.js', array('jquery'));

The problem is, I'm deregistering jquery in my functions.php file within my theme, to get version 1.7.2. But it still takes the version 1.6.4..

I do like:

    wp_deregister_script( 'jquery' );
    wp_register_script('jquery', (get_template_directory_uri() . "/js/jquery-1.7.2.min.js"), false, '1.7.2');
    wp_enqueue_script( 'jquery' );

Does any know, why it takes the 1.6.4, and not version 1.7.2?


share|improve this question
because the priority of the slider and 1.6.4 means it is executed after the 1.7.2 – Tom J Nowell Apr 11 '12 at 14:46
How can I change that? – Zerpex Apr 11 '12 at 14:51
when the function is added, specify a different priority, is your functions.php code inside a hook or is it loose in the global scope? Also can you modify your code to show where thethe_image_slider_head_scripts is getting added so that I can see what priority if any it is being given? – Tom J Nowell Apr 11 '12 at 14:57
@TomJNowell Please don't post answers as comments. – Chip Bennett Apr 11 '12 at 15:04
I haven't enough information to fully compose an answer below. When I do I will write up a full answer – Tom J Nowell Apr 11 '12 at 15:05
up vote 2 down vote accepted

First: do not de-register core-bundled scripts in order to register some arbitrary version of those scripts.

WordPress currently (at time of writing) comes bundled with jQuery 1.7.1. When WordPress 3.4 comes out next month, that version will be (IIRC) 1.8.x. Core, Themes, and other Plugins will all rightfully expect the core-bundled version of jQuery to be in use. Also, the core-bundled version of jQuery uses no-conflict mode, which may not be true when registering an arbitrary version of the script. Thus, you introduce more potential script breakage.

Second: to override a script de-register/enqueue in a Plugin, you need to hook into the same action, and utilize hook priority.

Assuming the Plugin callback unction thethe_image_slider_head_scripts() {} is using the default priority, 10, then your own callback needs to use a lower priority (i.e. a higher number), such as 11, like so:

function wpse48638_enqueue_scripts() {
    // Theme script enqueues go here
add_action( 'wp_enqueue_scripts', 'wpse48638_enqueue_scripts', 11 );

Alternatively, you can remove the Plugin callback from the action, and then enqueue your own scripts as per normal. Note: the remove_action() call must use the same priority as the Plugin add_action() call:

remove_action( 'wp_enqueue_scripts', 'thethe_image_slider_head_scripts' );

(Note that, in both cases, you need to reference the same action that the Plugin is using. It may be wp_head or even init, instead of wp_enqueue_scripts.)


Based on this comment:

Let me see, when I search for the function: thethe_image_slider_head_scripts add_action('wp_print_scripts', "thethe_image_slider_head_scripts");

That's exactly what we need!

If you simply want to remove the Plugin's script enqueues, just call:

remove_action( 'wp_print_scripts', 'thethe_image_slider_head_scripts' );

You have to use the same priority as the add_action() call, so be sure to leave it as the default (10).

Edit 2

So, there's one more thing you may need to do, based on this little nugget of wisdom from the Codex:

It is also worth noting that you may need to prioritise the removal of the action to a hook that occurs after the action is added. You cannot successfully remove the action before it has been added.

Note: I had to download the Plugin, which required a free "club" membership from the developer, to find this solution. Seeing the full code is imperative to answering these sorts of questions.

The add_action( 'wp_print_scripts', 'thethe_image_slider_head_scripts' ) function is called from within another callback, that itself is hooked into init. That's why your remove_action() call is failing: because it is firing at an earlier action, when the action you're trying to remove hasn't yet been added. So, you need to wrap your remove_action() call inside of a callback also hooked into init, like so:

function wpse48638_init_functions() {
    // Remove TheThe Image Slider scripts
    remove_action( 'wp_print_scripts', 'thethe_image_slider_head_scripts' );
add_action( 'init', 'wpse48638_init_functions' );

Note also that you will probably also need to re-enqueue the 'slider-ui' script that's part of the callback you're removing.

share|improve this answer
I know that current version of wordpress gets delivered with 1.7.1, the plugin overwrites the standard jquery. Also from a performance view, loading a jquery internally on the page isn't good, rather using a jquery, from google CDN, because often the jquery is already cached within' the users browser. – Zerpex Apr 11 '12 at 16:00
I've tried both the remove_action, and setting the priority higher than the loaded jquery. It doesn't work for some reason. – Zerpex Apr 11 '12 at 16:09
The Plugin shouldn't do that, period. Doing that will cause breakage, whether done in a Plugin or in a Theme. Your question is prima facie evidence of such breakage. – Chip Bennett Apr 11 '12 at 16:26
"I've tried both the remove_action, and setting the priority higher than the loaded jquery. It doesn't work for some reason." - For more precise suggestions, we will need to see ALL of the relevant code from both the Plugin and from your Theme, including the full callbacks, and the add_action() calls. – Chip Bennett Apr 11 '12 at 16:27
Let me see, when I search for the function: thethe_image_slider_head_scripts add_action('wp_print_scripts', "thethe_image_slider_head_scripts"); – Zerpex Apr 13 '12 at 6:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.