WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Does this look correct and would there be any reason why this isn't working?

In functions.php...

* Enqueue scripts and styles
function dcp_custom_scripts() {
    wp_register_script('expand', get_template_directory_uri() . '/scripts/expand.js', array('jquery') );

add_action( 'wp_enqueue_scripts', 'dcp_custom_scripts' );

I've tried numerous variations from hundreds of articles online and nothing seems to work.

This is a modified off-the-shelf theme built by someone else. They have manually inserted all scripts and styles directly in the <head> so it's a bit of a mess.

Whatever I try, no scripts that I enqueue appear in the <head> at all, so it's not even attempting to work.

share|improve this question
Are you sure the path to the js file is correct? – Chittaranjan Dec 13 '13 at 18:08
@Chittaranjan Yes, definitely correct - even if it wasn't though, it would still try to enqueue it and display in the <head> wouldn't it, but just 404...? Thanks. – zigojacko Dec 16 '13 at 9:35
Yes, it will definitely include the file. If clicking the js file url in the browser source code gives you 404, then surely the file path is not correct. Please compare the path with your theme js file path and correct accordingly. – Chittaranjan Dec 16 '13 at 9:48
I've already said, the path is definitely correct... You completely misunderstood my last comment. – zigojacko Dec 16 '13 at 10:01
Then what's the meaning of 404 in your comment? – Chittaranjan Dec 16 '13 at 10:03

On your header.php file, can you check if this function <?php wp_head(); ?> exists ? If not, then just add the code <?php wp_head(); ?> before the closing head tag </head>

share|improve this answer
No it doesn't - sorry I forgot to mention - the functions.php file includes remove_action('wp_head', 'wp_generator'); (even with this commented out though, enqueuing still wasn't working). Thanks. – zigojacko Dec 13 '13 at 18:07
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. – s_ha_dum Dec 13 '13 at 18:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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