Hi. I am trying to figure out how to use jQuery in WordPress. is there a special syntax I have to use? I;ve tried countless times and now, I see I need help. Any help would greatly be appreciated.
Hi. I am trying to figure out how to use jQuery in WordPress. is there a special syntax I have to use? I;ve tried countless times and now, I see I need help. Any help would greatly be appreciated.
Use the jQuery built-in to WordPress and ALWAYS use the wp_enqueue_script() function to add your scripts correctly.
http://codex.wordpress.org/Function_Reference/wp_enqueue_script
So, to use jQuery on the front end of your site use something like:
function add_jquery() {
wp_enqueue_script( 'jquery' );
}
add_action('wp_enqueue_scripts', 'add_jquery');Thank you, David.
Oh also, do I add this in the head?
No.
It get's added to the header via the add_action('wp_enqueue_scripts', 'add_jquery'); hook.
Just add the code anywhere inside your themes functions.php file.
You must log in to post.