It's pretty standard, I enqueue script and style for admin page.

function admin_custom(){
    wp_enqueue_script('js', plugins_url('adm.js', __FILE__));
    wp_enqueue_style('css', plugins_url('adm.css', __FILE__));

add_action('admin_enqueue_scripts', 'admin_custom');

The result:

<link rel='stylesheet' id='css-css'  href='http://localhost/wp/wp-content/plugins/manager/adm.css?ver=3.5.1' type='text/css' media='all' />
<script type='text/javascript' src='http://localhost/wp/wp-content/plugins/manager/adm.js?ver=3.5.1'></script>

But it doesn't work. Style is working, but the script is not loaded. I put the css and js in the same folder. It doesn't make sense for me. Any help will be appreciated, I spent last day for this problem. Thanks!

  • when you say the script is not loaded, is it returning a 404?
    – Milo
    Mar 11, 2013 at 2:08
  • @Milo: I used inspect element in Chrome, when I clicked css link, my code was there, but when I clicked js link, it was blank.
    – shankshera
    Mar 11, 2013 at 2:14
  • That code should work, and does work when I test it. Make sure the path is correct and check the permissions on the file.
    – s_ha_dum
    Mar 11, 2013 at 4:10

1 Answer 1


I was having this same problem too, turns out the function wp_enqueue_scripts(), removes any blank spaces from your template directory folders. So say your folder name is this theme, the function will make it thistheme, which will then cause an incorrect directory link. Try changing the folder names around if this is the case, otherwise it worked for me so good luck!

  • 1
    An additional note: this is because (unencoded) spaces are invalid characters in URLs. Even if wp_enqueue_scripts didn't strip the spaces there is a good chance the URL wouldn't work.
    – s_ha_dum
    Jul 10, 2013 at 2:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.