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

my wp_enqueue_script does not seem to work, i can't understand why :

i have a child theme of twenty ten,
i wrote this in my functions.php file (in my theme) :

function my_scripts_method() {
        get_stylesheet_directory_uri() . '/js/patScript.js',
add_action('wp_enqueue_scripts', 'my_scripts_method');

then in my header :

<script type="text/javascript" src="<?php get_stylesheet_directory_uri().'/js/patScript.js'; ?>"></script>

and the file is :

$(function () {

But alert does not work. The path is correct, when i echo get_stylesheet... it gives me the right path where my file is located. Would you have any idea?

Thanks a lot

EDIT : the console in Firefox tells me that :

$(function () {

"is not a function" : does it mean it does not recognize jquery? i added :


above my previous enqueue script, but same thing...

share|improve this question
up vote 1 down vote accepted

Two things-

When you enqueue a script, WordPress inserts the script tag in the call to wp_head(), so step one is to remove the script tag from your header.

The second thing is the jQuery supplied with WordPress is in no conflict mode by default, so you should reference the jQuery object with jQuery rather than $:

jQuery(function () {
share|improve this answer
great! It such a relief when the thing finally works! :p thanks ! – Paul May 15 '12 at 4:25

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.