Treehouse: Grow your CSS skills. Land your dream job.

jQuery Plugin Files won’t ever work!!

  • # November 1, 2012 at 7:06 am

    Hi guys,

    Thanks in advance for any help anyone will give me!

    have a good understanding of WordPress and I have been able to create my own custom theme from scratch and manipulate it the way I want to.

    The next step for me was to implement some cool jQuery plugins to extend my abilities!

    The thing is I’ve tried every single tutorial out there, read everyting about wp_enqueue and wp_register etc. etc. !

    The good news: I can see both jQuery and any other custom jQuery script I use, loading in the source of a browser in the header.

    The bad news: Although the custom script is being loaded it isn’t working.

    Here is some example code from my theme’s functions.php :

    (Oh before that: I am using “Use Goggle Libraries” WordPress Plugin to load jQuery, so I’m not queueing it again in the functions.php).

    function custom_scripts_load()

    // Register the script like this for a theme:
    wp_register_script( ‘custom-script’, get_bloginfo(‘template_directory’) . “/js/custom-script.js” );
    // For either a plugin or a theme, you can then enqueue the script:
    wp_enqueue_script( ‘custom-script’ );
    add_action( ‘wp_enqueue_scripts’, ‘custom_scripts_load’ );

    And the simplest of javascript just to test it in my custom-script.js file :

    $(function)() {


    So to recap: I can see botH , jQuery and custom-script.js loading in the Source


    Nothing ever really happens.

    Any help would be extremely appreciated!

    Thanks once again in advance.

    # November 1, 2012 at 9:20 am

    You have a closing bracket misplaced. Try this:

    $(function() { $(“body”).css(“background”,”blue”);

    Or perhaps even better:


    # November 1, 2012 at 9:28 am

    Hey Senff,

    Thanks for replying.

    Tried it and I get an error:

    ‘undefined’ is not a function (evaluating’$(document)’)

    # November 1, 2012 at 9:34 am

    Don’t worry about it actually. I used this little snippet and it did work!

    (function ($) {

    # November 1, 2012 at 9:37 am

    Looks like there is a noConflict set there. You can also just do this then:


    # November 6, 2012 at 5:17 pm

    I often have messed up my jQuery scripts and plugins by leaving out the wp_head and wp_footer hooks. Their pretty essential.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.