Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I receive the error: wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or init hooks.

But my code looks perfectly fine to me in my theme's functions.php which you can see here:

<?php

// Register and Load jQuery Plugins
function enqueue_scripts(){
wp_enqueue_script('jquery'); // load jquery with theme
wp_enqueue_script('pulldown', get_stylesheet_directory_uri() . '/js/pulldown.js');
wp_enqueue_script('supersized', get_stylesheet_directory_uri() . '/js/supersized.3.2.7.min.js');
wp_enqueue_script('metadata', get_stylesheet_directory_uri() . '/js/jquery.metadata.js');
wp_enqueue_script('ytplayer', get_stylesheet_directory_uri() . '/js/jquery.mb.YTPlayer.js');
wp_enqueue_script('placeholder', get_stylesheet_directory_uri() . '/js/placeholder.js');
wp_enqueue_script('mediaqueries', get_stylesheet_directory_uri() . '/js/css3-mediaqueries.js');
wp_enqueue_script('countdown', get_stylesheet_directory_uri() . '/js/jquery.countdown.pack.js');

} add_action('wp_enqueue_scripts', 'enqueue_scripts');

?>

Can you see a problem here?

share|improve this question
are you using any plugins? – Milo Feb 18 at 21:08
Maybe a plugin is using the same function name as you. What happens when you use a properly prefixed function name? – toscho Feb 18 at 21:15
Disable all Plugins, change Theme to Twenty Twelve, and verify the error message disappears. Then switch back to your Theme, and verify whether the error message appears. If it does, the problem is in your Theme, and you'll need to look for other calls to wp_enqueue_script() than the ones you've included in your question. If the error message does not appear after switching to your Theme, the problem is in one of your Plugins. Re-enable Plugins, one-by-one, until you determine the culprit. – Chip Bennett Feb 18 at 21:53
Do you have a line number to go with that error? Are you sure it is this code causing the problem? – s_ha_dum Feb 18 at 21:54
Deactivated all themes & plugins and yes it looks like a plugin is causing this error, this plugin is wordpress.org/support/plugin/ajax-contact-me – Ben Jackson Feb 18 at 22:27
show 1 more comment

closed as too localized by toscho Mar 18 at 23:27

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

Browse other questions tagged or ask your own question.