Following How to add a javascript snippet to the footer that requires jQuery I am trying to load jQuery before my script does stuff but it's not working.
This is it working when I include jQuery manually
This is it not working when I do it the right way.
In that previous question, the answerer says I should put my script material inside an if( wp_script_is( 'jquery', 'done' ) ) {
, and I tried that too but the part within the if
never gets executed.
wp_enqueue_scripts
hook rather than more genericwp_head
.wp_enqueue_script( 'jquery' );
outside ofmyscript_jquery()
function. It's working now. :)wp_localize_script
to pass data from php to javascript, no need to print it directly to the page yourself.