Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

WordPress

Diana Myers
Diana Myers
2,955 Points

Correctly add jquery-ui to Wordpress theme

How do I correctly add jquery-ui.min.js, jquery_ui.css and the script snippet to a theme?

2 Answers

Diana Myers
Diana Myers
2,955 Points

Thanks for trying to be helpful, but I needed all the code elements - coding for jquery-ui.min.js, jquery_ui.css and the script snippet to add to the theme code. Fortunately, I found a plugin - jQuery UI Widgets.

shahardekel
shahardekel
20,306 Points

James is right. I just want to add a little more info: The 'wordpress way', is to use wp_enqueue_script, usually in your theme's functions.php file. You'll want to add a jquery dependency to it, as jquery UI depends on it.

It can looks something like this (inside functions.php): ``` function theme_scripts() { wp_enqueue_script( 'jquery-ui', get_stylesheet_directory_uri() . '/js/jquery-ui.js', array( 'jquery' ) ); } add_action( 'wp_enqueue_scripts', 'theme_scripts');