How to enqueue custom JS script to WordPress functions.php

Last updated on

Open functions.php in your WordPress themes folder, usually located in /wp-content/themes/{theme_name}/

Add the following code to the end of functions.php

function custom_scripts() {
	wp_register_script( 'owl', get_template_directory_uri() . '/assets/js/owl.carousel.js' );
add_action( 'wp_enqueue_scripts', 'custom_scripts' );

In the above example we are enqueuing the Owl Carousel script.

Let me know if this helped. Follow me on Twitter, Facebook and YouTube, or 🍊 buy me a smoothie.

Leave a reply

Your email address will not be published. Required fields are marked *