I have been beating my head against this for a couple of hours now and can't seem to figure it out. I am trying to enqueue a script into my page with the following code in my functions.php.

function my_slider_scripts() {
$scriptsrc = get_stylesheet_directory_uri().'/js/jquery.nivo.slider.pack.js';
wp_register_script( 'nivo-slider-pack', $scriptsrc );


add_action( 'wp-enqueue_scripts', 'my_slider_scripts' );

I have looked at the codex and every tutorial I can find and nothing seems to make this work. I should mention I am using a child theme. Any ideas would be greatly appreciated.

3 Answers 3


try add_action('wp_enqueue_scripts', 'my_slider_scripts')

the hook doesn't have a dash. It's an underscore.

  • i fixed the typo and the scripts are still not being included in the page. Is there something that needs to be added to the page template file?
    – micahmills
    Jul 25, 2012 at 1:37
  • 1
    You have wp_head() and wp_footer() calls in your header and footer templates, right? Jul 25, 2012 at 2:33
  • yes! To be honest I moved onto another solution for this. It was taking to much time. Thanks for your help though.
    – micahmills
    Jul 25, 2012 at 22:08

(i deleted my old answer in favour of this)

  1. Check the Location ... is the Nivo Slider in your theme / stylesheet folder or in the plugins directory?

You're currently using $scriptsrc = get_stylesheet_directory_uri().'/js/jquery.nivo.slider.pack.js';

maybe it should be

function my_scripts_method() {  
wp_enqueue_script('my-script', plugins_url('/js/jquery.nivo.slider.pack.js', __FILE__), array('jquery'));

add_action('wp_enqueue_scripts', 'my_scripts_method');  

Here is some information for you so that you understand how things work with wp_enqueue_scripts.

You need to know the priority order for the wp_enqueue_scripts. Please check the below order of the hooks can be run........

  1. muplugins_loaded
  2. registered_taxonomy
  3. registered_post_type
  4. plugins_loaded
  5. sanitize_comment_cookies
  6. setup_theme
  7. load_textdomain
  8. after_setup_theme
  9. auth_cookie_malformed
  10. auth_cookie_valid
  11. set_current_user
  12. init
  13. widgets_init
  14. register_sidebar
  15. wp_register_sidebar_widget
  16. wp_default_scripts
  17. wp_default_stypes
  18. admin_bar_init
  19. add_admin_bar_menus
  20. wp_loaded
  21. parse_request
  22. send_headers
  23. parse_query
  24. pre_get_posts
  25. posts_selection
  26. wp
  27. template_redirect
  28. get_header
  29. wp_head
  30. wp_enqueue_scripts
  31. wp_print_styles
  32. wp_print_scripts

... and so one.....

So you see you can add it in the init hook and doing so it will be called as high priority than below the listing.

If you found your files are not loading and you surely can use a high priority hook.

If you found your wp_enqueue_script is not being called, you can use this simple trick to get it work for your theme or plugin.


    function my_slider_scripts() {
$scriptsrc = get_stylesheet_directory_uri().'/js/jquery.nivo.slider.pack.js';
wp_register_script( 'nivo-slider-pack', $scriptsrc );


        add_action( 'init', 'my_slider_scripts' );

  • init should not be used to enqueue scripts, always use wp_enqueue_scripts.
    – Milo
    Mar 18, 2014 at 17:39
  • In my answer I show you why and in which situation you should use init hook.
    – Sabbir H
    Mar 19, 2014 at 8:24
  • In your answer you give no compelling reason why you should use the wrong hook, and how it would possibly fix the issue.
    – Milo
    Mar 19, 2014 at 14:45

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.