WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

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

I've included the javascript by

wp_enqueue_script('slider', plugins_url( 'slider.js', __FILE__ ) );

with just a simple

$(document).ready(function () {

It shows up in the browser but doesn't prompt me with "alert".

PS: Forgot to mention I've also included the jquery, but still not working.

wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", false, null);

In addition to the answers, I also had to tell wordpress that my script depends on jQuery

wp_enqueue_script( 'slider', plugins_url( 'slider.js', __FILE__ ),array('jquery') );
share|improve this question
up vote 0 down vote accepted

A few things:

  1. The version of jQuery that ships with WordPress is run in noConflict() mode. Meaning you have to use jQuery instead of $ when you make your first reference.
  2. Don't register your own version of jQuery when you're developing. You're locking yourself in to a single version that may or may not be compatible with WordPress' other requirements.
  3. You can use the browser console to test things. Open your page, then hit F12 to launch the console. Type jQuery into the console and see whether or not it returns the correct object.
share|improve this answer

WordPress loads jQuery in "No Conflict" mode. The $ alias does not work. Use jQuery.(document) or wrap your code like...

(function($) { 
  $(function() {
    // more code using $ as alias to jQuery
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.