Title: Using jQuery and WordPress
Last modified: August 19, 2016

---

# Using jQuery and WordPress

 *  [aaron-s](https://wordpress.org/support/users/aaron-s/)
 * (@aaron-s)
 * [17 years ago](https://wordpress.org/support/topic/using-jquery-and-wordpress/)
 * Hello all. I just began learning how to develop WordPress templates, and I have
   mostly finished all the features I wanted to include in my first template, except
   one.
 * I wanted to have a jQuery powered image slide show on the main page– which is
   just a page template that is exactly like a regular index.php file.
 * I have a bunch of divs set up for each image, and caption on in the page template,
   above the posts area.
 * I then added the JavaScript in header.php. It for some reason does not work. 
   Am I doing something wrong?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [akaney](https://wordpress.org/support/users/akaney/)
 * (@akaney)
 * [16 years, 12 months ago](https://wordpress.org/support/topic/using-jquery-and-wordpress/#post-1093009)
 * I have recently ran into this problem myself, and would be interested in knowing
   if you find a solution.
 *  [Tynan Beatty](https://wordpress.org/support/users/junsuijin/)
 * (@junsuijin)
 * [16 years, 12 months ago](https://wordpress.org/support/topic/using-jquery-and-wordpress/#post-1093010)
 * Instead of just adding the javascript (if you did it manually), you should use
   [wp_enqueue_script](http://codex.wordpress.org/Function_Reference/wp_enqueue_script)
   to avoid clashing with plugins that also use jQuery. You’d just need to call `
   wp_enqueue_script('jquery');` before the `wp_head();` or before `get_header();`
   
   Or if you are using an external js file like you should, then you’d have to do
   something like `wp_enqueue_script('my-script', '/wp-content/themes/my-theme/my-
   script.js', array('jquery'), '1.0');`
 * Make sure to note that WordPress loads jquery in noconflict mode, so you have
   to format your jQuery as follows:
 *     ```
       jQuery(function($){
       some code...
       });
       ```
   
 * if you want to use the $ function.
 * If you find that your theme isn’t printing out the `<script...>...</script>` 
   then you can use the functions.php to `add_action('wp_footer', 'wp_print_scripts');`
   or just manually call wp_print_scripts(); somewhere in the theme where you want
   them to print. Be careful if doing something like this though, because you’ll
   probably want to also include something in the functions.php to `remove_action('
   wp_head', 'wp_print_head_scripts', 9);`
    and `remove_action('wp_footer', 'wp_print_footer_scripts');`.
   To avoid printing jQuery twice if you enqueue it after the `wp_head();` peace
   ~

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Using jQuery and WordPress’ is closed to new replies.

 * 2 replies
 * 3 participants
 * Last reply from: [Tynan Beatty](https://wordpress.org/support/users/junsuijin/)
 * Last activity: [16 years, 12 months ago](https://wordpress.org/support/topic/using-jquery-and-wordpress/#post-1093010)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
