I’m trying to add styles and scripts to my plugin so I use:
function add_my_scripts() {
wp_register_script( 'test_scripts', plugins_url('test_scripts.js', __FILE__) );
wp_enqueue_script( 'test_scripts' );
}
add_my_scripts();
in my plugin page but it adds the script to the footer rather than inside the tags. The same thing happens with wp_enqueue_style. I read that it’s supposed to add the script or style to the head by default. I don’t know what the problem is.
Possible cause:
wp_head()
is missing from the header or is in the wrong place or somehow isn’t getting called. Are other scripts loading in head correctly?Also, did you try passing ‘false’ as the last parameter to
enqueue_script()
to force it to go in the header? This really shouldn’t fix the problem, but it would be something I’d try if I couldn’t figure something else out.