I'm trying to register & enqueue ImageMapster in my Skeleton Child Theme on the main.php page to make an image map with hovering image effects. I added this code to the "Header Functions" section of my child theme's functions.php file:

add_action( 'wp_enqueue_scripts', 'load_custom_js' );
function load_custom_js() {
    wp_register_script( 'jquery.imagemapster.js', 
    get_template_directory_uri() . '/javascripts/jquery.imagemapster.js', 
    array('jquery'), '1.2.6', false );

    if ( is_page('Main') ) {
    wp_enqueue_script( 'jquery.imagemapster.js', 
    get_template_directory_uri() . '/javascripts/jquery.imagemapster.js', 
    array('jquery'), '1.2.6', false );

Now my site has ceased to work. The javascript file is located in the parent theme directory, so is it correct to use get_template_directory_uri instead of get_stylesheet_directory_uri? Does each theme have a particular place where one should add custom functions or am I correct in adding it under "Header Functions"? Any help would be appreciated.

2 Answers 2


One problem: if you define the script in a wp_register_script() like so:

    get_template_directory_uri() . '/javascripts/jquery.imagemapster.js', 

...then you only need to reference the defined script's name in the wp_enqueue_script() call, like so:

wp_enqueue_script( 'jquery.imagemapster.js' );

Re-declaring all of the parameters in wp_enqueue_script() shouldn't cause the fatal error you describe; however, it could cause unintended consequences (especially if the declarations do not match between wp_register_script() and wp_enqueue_script()).


Have you tried using get_template_directory()? This should actually return the parent theme's directory when called from your child theme's functions.php.

Out of curiosity, does the path of your child theme's directory get returned when you're calling get_template_directory_uri right now from your child theme?

  • I figured it out - I had accidentally deleted a critical ?> tag from a different function. Everything works fine now.
    – jess
    Commented Oct 2, 2012 at 22:36

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.