This is something that has always confused me and I could use some help.
I want to do four things directly above the closing body tag:
- include jQuery (WordPress version is fine)
- include a jQuery plugin dependent on jQuery beneath this
- initialize the plugin directly underneath this plugin AND avoid conflict issues using $ instead of jQuery
- do this only on specific page templates or theme files
I understand that I probably should be using wp_enqueue_script, but I'm not sure if I should use that in functions.php or just directly on the page where I want it.
Regarding number 3 I have seen the workarounds such as:
jQuery(function ($) {
/* You can safely use $ in this code block to reference jQuery */
});
But I'm honestly confused as to how to implement this.
What's the best way to accomplish this?
Thanks very much.