I created this theme and it worked on my site without any problem. When I moved it to another server, I get wp_register_script was called incorrectly. error.

I scanned my source code and I didn't use any wp_register_script ... however I am suspecting that it is reacting to this ...

function add_script_code() {
    wp_enqueue_script('jquery', base_url('source/js/jquery-1.4.1-vsdoc.js'), false, '1.3.0', TRUE );
    wp_enqueue_script('less', base_url('source/js/less-1.3.0.min.js'), false, '1.3.0', TRUE );
    wp_enqueue_script('vars', base_url('source/js/vars.js'), false, '1.3.0', TRUE);
    wp_enqueue_script('function', base_url('source/js/function.js'), false, '1.3.0', TRUE );

//add_action('admin_init', 'add_script_code');
add_action('wp_footer', 'add_script_code')

My code base is in github. The functions folder contains my functions for the theme.


Base url is a function I created.

function base_url($url) {
        return get_bloginfo('template_url').'/'.$url;
  • 1
    Particularly, I've never seen this base_url used before...
    – brasofilo
    Jan 9, 2013 at 11:50
  • Sorry about that. I added the fucntion for it. It is also on the default_func.php file. @brasofilo
    – Mr A
    Jan 9, 2013 at 12:41
  • I believe that wp_enqueue_script() code should be attached to an early hook, like wp_head or wp_enqueue_scripts, and the fifth argument will load the script in footer
    – shea
    Jan 9, 2013 at 12:46
  • Why did my theme work on my other server then? This error only happened when I move it in another wp install. @bungeshea Also, could you cite and example?
    – Mr A
    Jan 9, 2013 at 12:48
  • I don't know why you are receiving different server responses, but see my answer below for guidance on how to fix your issue
    – shea
    Jan 9, 2013 at 12:58

3 Answers 3


You need to hook your function into either wp_enqueue_scripts, admin_enqueue_scripts, or init. wp_footer is too late to enqueue scripts; they need to be enqueued before the wp_head() function is called.

The fifth argument of the wp_enqueue_scripts() function, when set to true, will load the script in the page footer instead of header. From the Codex:

You have to enqueue your script before wp_head is run, even if it will be placed in the footer

  • I tried editing ... add_action('wp_footer', 'add_script_code') to add_action('init', 'add_script_code') but still gave me the same error.
    – Mr A
    Jan 9, 2013 at 13:36

Are the WordPress versions the same on both servers? I believe the notice was added in version 3.3. Also, bungeshea is right about enqueueing your script before wp_head is run - meaning you should be hooking into either init or wp_enqueue_scripts hook.

oh yeah, the 3rd argument should be an array not boolean so the call should look like this:

wp_enqueue_script('function', base_url('source/js/function.js'), array(), '1.3.0', TRUE );
  • You should actually use false for the third argument if your script has no dependencies. See the Codex for details
    – shea
    Jan 9, 2013 at 21:18
  • @bungeshea: the Codex does not use false ;) The parameter type clearly says it should be an array. In fact, the default value for the 3rd paramter is an empty array() which is used when there are no dependencies.
    – WP Themes
    Jan 17, 2013 at 15:22
  • Read again: Array of handles of any script that this script depends on (scripts that must be loaded before this script). false if there are no dependencies
    – shea
    Jan 17, 2013 at 22:49

I found the culprit. My theme was written in short tags. My server short tags was off. So I just converted my theme to use <?php and everything worked.

Thanks for helping me.

  • Please accept your answer using the tick to the left of your answer
    – shea
    Jan 9, 2013 at 21:19

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.