WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

ok this is my first time to include jQuery into wordpress and it has taken me the 2 full days trying to figure this out. No matter how many articles I read I cannot find a perfect example.

Ok so this is my plugin file... very simple.

    Plugin Name: jQuery Include Test
    Plugin URI: http://jquery.com
    description: A test to include jQuery.
    Author: blah blah
    Author URI: 

// jQuery alert to pop up when the page loads.

    function pop_jquery_test() {
    $src = plugins_url('includes/jquerytest.js', __FILE__);
    wp_register_script( 'jquerytest', $src );
    wp_enqueue_script( 'jquerytest' );
    wp_enqueue_script( 'jquery' );

and this is the jquerytest.js file that



 alert('hi there');

now the question is how do i get this to work? in the sense when i activate the plugin, it pops-up like the jquery code above says.

share|improve this question
I guess it doesn't work because you're queuing jQuery after your own script. Try moving wp_enqueue_script('jquery') to the top. – Rutwick Gangurde Feb 17 '12 at 4:01
You can set the variable $j to be jQuery.noConflict(), but then you should use $j instead of how you are using it currently ($jQuery), and as Rutwick Gangurde said, enqueue jQuery before your script. – Jared Feb 17 '12 at 4:03
up vote 4 down vote accepted

Your jQuery is wrong. what you want is jQuery(docu.... not $jQuery(docu....

You should try to make sure the components work individually before you put them together (within reason of course), it will make troubleshooting MUCH easier for you.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.