0

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') );
    wp_enqueue_script('expand');
}

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.

6
  • Are you sure the path to the js file is correct? Dec 13, 2013 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, 2013 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. Dec 16, 2013 at 9:48
  • I've already said, the path is definitely correct... You completely misunderstood my last comment.
    – zigojacko
    Dec 16, 2013 at 10:01
  • Then what's the meaning of 404 in your comment? Dec 16, 2013 at 10:03

1 Answer 1

0

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>

1
  • 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, 2013 at 18:07

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.