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

The title pretty much explains exactly what I'm trying to do. If someone could help me out, that would be awesome. Thanks!


share|improve this question
up vote 2 down vote accepted

the correct way to include files for scripts you can use the hook "admin_print_scripts"

and include your scripts with wp_enqueue_script()

for example:

function my_scripts(){
   wp_enqueue_script( 'jquery' );

and for styles use the hook "admin_print_styles" and include you styles with wp_enqueue_style

for example:

function my_styles(){
   wp_enqueue_style( 'myPluginStylesheet', WP_PLUGIN_URL . '/myPlugin/stylesheet.css' );

Hope This Helps.

share|improve this answer

jQuery should already be loaded, it's used throughout the admin area of WordPress.

If you want to include some of your own jQuery, just enqueue the script and set jQuery as a dependancy.

function enqueue_my_script(){
    // Uncomment line below if using inside a plugin
    //wp_enqueue_script( 'my-script', plugins_url( 'myfile.js', __FILE__ ), array( 'jquery' ) );
    // Uncomment line below if using inside theme functions.php
    //wp_enqueue_script( 'my-script', get_bloginfo( 'stylesheet_directory' ) . '/myfile.js', array( 'jquery' ) );

%HANDLE% should be appropriately changed for the handle of your registered page, it's the fifth parameter in add_menu_page and the fourth in add_submenu_page and others such as add_theme_page.

This method will ensure the enqueue is only made for your specific custom page, and not every admin page.

I also covered using registered handles to selectively enqueue in URLs of plugin resources?

Hope that helps..

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.