So i've been trying to figure this out for awhile now. The following code does not seem to work for me. The javascript file will not be included in the footer ( or anywhere for that matter )

function add_scripts_plz(){
     wp_enqueue_script( 'wowjs', get_template_directory_uri() . '/js/wow.min.js', array('jquery'), '2', true );
 add_action('wp_enqueue_scripts', 'add_scripts_plz');

If I were to just include this in functions.php outside of the action like so:

 wp_enqueue_script( 'wowjs', get_template_directory_uri() . '/js/wow.min.js', array('jquery'), '2', true );

everything works fine, except for I get the warning message about improperly using the function and I'd like to only enqueue scripts on certain pages anyways...

Any ideas why it's not working inside of the wp_enqueue_scripts function ?

  • I tested your code as posted (the first block) and it works exactly as expected. Do you see the appropriate <script line in the page source? If so, what is the associated URL and is there a file in that location?
    – s_ha_dum
    Apr 3 '15 at 14:42
  • Don't see the script line in page source. I'm wondering if maybe there is deeper issue causing it not to work. I don't see anything in error logs though.
    – sirmdawg
    Apr 3 '15 at 19:04
  • There is something deeper causing this to fail. Did you notice the question in my first comment? Have you tried disabling plugins and switching themes?
    – s_ha_dum
    Apr 3 '15 at 19:05

Try changing wp_enqueue_script() to wp_register_script() and then after that add wp_enqueue_script('wowjs');


The first example is correct. Only if you use a child theme you need to use get_stylesheet_directory_uri() instead of get_template_directory_uri().

I assume there is another problem elsewhere. You should check your PHP error log.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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