Support » Fixing WordPress » Cannot Enqueue Scripts?

  • Hi all,

    I’m attempting to load a javascript file (eventually will be multiple js and css) into the header of the site. As far as I can tell, it should be a simple process of defining a custom function in functions.php and using add_action() to register it?

    Here is my code (in functions.php):

    function load_scripts_and_styles() {
    	$root = get_theme_root_uri();
    	$dir = $root . 'evos/js/functions/functions.js';
    
    	wp_enqueue_script('functions', $dir);
    }
    add_action( 'wp_enqueue_scripts' , 'load_scripts_and_styles' );

    I cannot understand why this isn’t working, I would of thought it would be simple or at the least I would get some kind of error?

    Thanks in advance

Viewing 3 replies - 1 through 3 (of 3 total)
  • Have you tried displaying the $dir variable after it’s set?

    You mean simply echo it out?

    $dir contains the correct filepath but I have only been able to test this outside of load_scripts_and_styles().

    What I mean to say is the function doesn’t seem to get called at all.. even a simple echo isn’t displayed which makes me think it’s a problem with the add_action() but I’m just taking blind stabs in the dark right now!

    Can you post the entire functions.php on pastie.org and share the URL here?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Cannot Enqueue Scripts?’ is closed to new replies.