Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to implement a jQuery accordion for a client of ours. Basically, it's this tutorial (http://wp.tutsplus.com/tutorials/creative-coding/create-an-faq-accordion-for-wordpress-with-jquery-ui/) but having problems enqueuing the jQuery.

Basically, this is the code that is trying to enqueue the accordion script from the tutorial:-

add_action( 'wp_enqueue_scripts', 'fl_enqueue' );

function fl_enqueue() {
        wp_register_style('fl-jquery-ui-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/south-street/jquery-ui.css');
        wp_enqueue_style('fl-jquery-ui-style');
        wp_register_script('fl-custom-js', get_template_directory_uri() . '/faq/faq.js', 'jquery-ui-accordion', '', true);
        wp_enqueue_script('fl-custom-js');
}

When loading the page with Firebug, I'm getting the error TypeError: jQuery(...).accordion is not a function. I also cannot seem to see the accordion script being enqueued. However, the faq.js IS being loaded (which I think is odd, as it's a dependancy of the accordion script).

Baffled by this, any ideas?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

The 3rd parameter in the call to wp_register_script() should be an array of dependencies - not a string.

Change this:

wp_register_script('fl-custom-js', get_template_directory_uri() . '/faq/faq.js', 'jquery-ui-accordion', '', true);

To:

wp_register_script('fl-custom-js', get_template_directory_uri() . '/faq/faq.js', array('jquery-ui-accordion'), '', true);

share|improve this answer
    
Cheers that worked :) - loading the script but the accordion isn't working. Should be easy to figure out why though..... –  Rhys Wynne Feb 8 '13 at 13:37

Your Answer

 
discard

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.