How to include jquery-ui library in WordPress?

I’m trying to load the jQuery UI library into a WordPress plugin using this enqueue statement:

wp_enqueue_script('jquery');
wp_enqueue_script('jquery-ui-core');

The jQuery library loads fine, but the ui-core is MIA. The only way I can get ui-core functions to fire is to load the library with a static include like this:

Read More
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.15/jquery-ui.min.js"></script>

What am I missing?

Related posts

Leave a Reply

1 comment

  1. jquery is enqueued by default on admin side. So, it may not be loading due to your wp_enqueue_script statement.
    Are you using wp_enqueue_script inside some action hook? Because you have to. I use it like this:

    add_action( 'admin_enqueue_scripts-options_page-{page}', 'myplugin_admin_scripts' );
    function myplugin_admin_scripts() {
        wp_enqueue_script('jquery');
        wp_enqueue_script('jquery-ui-core');
    }