I need to “unhook” jQuery from my wp_footer()
… it’s being called automatically and I’m looking for something I can add to functions.php which prevents it from being called a second time in the footer (since I need to call it in the header)
please no editorial comments about why calling in the footer is better
You don’t want to unregister the script; that would make it unavailable to be enqueued. Rather, you want to dequeue the script.
You have two choices:
wp_enqueue_script( 'jquery' )
is called, you can simply callremove_action( 'wp_footer', 'callback_function_name' )
wp_dequeue_script()
.e.g.
Note: that priority is probably fairly important, since you’ll need to ensure that your dequeue call fires after the enqueue call.
Edit
Are you by chance viewing the Showcase Template (i.e.
showcase.php
)? Note that it enqueues a custom script:It adds jQuery to its dependents array, meaning that WordPress will first enqueue jQuery, and then enqueue
twentyeleven-showcase
. So, that might be the source of the mystery jQuery enqueue.(There’s also a
wp_enqueue_script()
call in/inc/theme-options.php
, but I don’t think that one would be impacting your front-end script-enqueueing.)the function to deregister any script is :
But the problem you have is different , if what I understand correctly – you have jQury included TWICE , once on header and once of footer . This is some plugin or theme function that is executed incorrectly – asking specifically to print in footer.. You might want to identify the problem better , for it can cause other problems …
Anyhow, example hooks are : (one init , one print_scripts)