Posts

Showing posts from March, 2016

How to add links to Javascript files in Wordpress Child Theme using wp_enqueue_script

Took some to figure this out. In your "functions.php" file in your child theme directory add this code function wpb_adding_scripts() { if (!is_admin()) { wp_register_script('my_amazing_script', get_stylesheet_directory_uri() . '/js/scroller.js', array('jquery'),'1.1', true); wp_enqueue_script('my_amazing_script'); } } add_action( 'wp_enqueue_scripts', 'wpb_adding_scripts' ); This function checks that you are not logged in as an administrator. my_amazing_script can be named anything you like get_stylesheet_directory_uri() is important if you're doing this in your child theme functions.php file 1.1 is your version number and can be anything true is to load the JS file at the bottom of the page, false is to load the JS file at the top of the page