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...

1 Answer 1


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 () {
  • great! It such a relief when the thing finally works! :p thanks !
    – Paul
    Commented May 15, 2012 at 4:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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