WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Maybe someone has prior experience with this, but when I include the jQuery UI 1.8.9 file within my admin_head I break the functionality of the dashboard (i.e. popup for adding featured image, drag and drop menu items, etc.). If I include 1.7.2, it doesn't break anymore but then my great little calendar won't work anymore.

So my questions is, currently (3.0.x),what is the best way to implement the jquery UI within admin pages without breaking everything?

(Other info: trying to add datepicker to a field within my custom post type)

Thank you!


share|improve this question
up vote 6 down vote accepted

WP 3.1 will come with jQuery UI 1.8 so the easiest solution would be to wait.

Also, it sounds like you're outputting the script tag directly. You should try deregistering the bundled jQuery UI version and replacing it with your own.

This is done using wp_deregister_script() and wp_enqueue_script().

share|improve this answer
Thanks scribu, that would probably explain it! – Noel Tock Feb 10 '11 at 18:30

Thanks again scribu, here the working result for anyone interested (custom-admin is just my js for the datepicker):

function wpse_9080_admin_head()
    global $pagenow;

    // Example of enqueue only in Profile page
    // based on scribu's suggestion in the comment bellow
    if ( 'profile.php' == $pagenow )
            wp_enqueue_style('ui-datepicker', get_bloginfo('template_url') . '/css/jquery-ui-1.8.9.custom.css');
            wp_enqueue_script('jquery-ui', get_bloginfo('template_url') . '/js/jquery-ui-1.8.9.custom.min.js', array('jquery'));
            wp_enqueue_script('ui-datepicker', get_bloginfo('template_url') . '/js/jquery.ui.datepicker.min.js');
            wp_enqueue_script('custom_script', get_bloginfo('template_url').'/js/custom-admin.js', array('jquery'));

add_action('admin_init', 'wpse_9080_admin_head');
share|improve this answer
You're welcome. However, you should limit your enqueuing to only the relevant admin screen. Check the $pagenow global. Also, you should prefix your function name with something unique, like my_admin_head() – scribu Feb 10 '11 at 20:52
Thanks, good point for the page. I'll have to see how it's handled in 3.1. No worries on the names, admin_head and custom_script are called otherwise, was just for showing. Thanks again! – Noel Tock Feb 11 '11 at 4:19

What would be right way to load jQuery UI only on custom post type page?

global $pagenow
if ($pagenow == 'post-new.php?post_type=events') {
// enqueue scripts here

is this correct way?

share|improve this answer

Your Answer


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.