Add Mootools to a Wordpress child theme

The following code, when included in the functions.php file in your Wordpress child theme, will correctly load Mootools and a custom script. This is the only way I am able make custom scripts work, but you hear a lot of stuff out there on the interweb…


<?php
function add_js() {
$stylesheet_dir = get_bloginfo('stylesheet_directory');
$myscript = $stylesheet_dir . '/js/myscript.js';
$mootools = $stylesheet_dir . '/js/mootools.js';
wp_enqueue_script('mootools', $mootools, '', '1.2.4', false);
wp_enqueue_script('myscript', $myscript, array('mootools'), '1.0', false);
}
add_js();
?>

Notice how every parameter is used in the < ?php wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); ?> function even though all but the first one is supposed to be optional. Maybe its a PHP thing. Whatever.

This entry was posted in Solutions, Wordpress. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>