how to enque scripts and css

Adding or Enqueue Jquery and CSS Right way in WordPress

WordPress comes by default with the latest version of JQuery and it’s relatively easy to add the reference to the scripts and css using a wordpress hook. Just add the code bleow to your functions.php file.

/**
 * Add the JQuery, Scripts and CSS Proper Way
 */
function wp_guru_enque() {
	wp_enqueue_style( 'style-name', get_stylesheet_uri() ); // Enqueue  style
	wp_enqueue_script( 'jquery' ); //Enqueue  jquery
	wp_enqueue_script( 'script-name', get_template_directory_uri() . '/scripts/script.js', array(), '1.0.0', true ); // Enqueue  script 
}

add_action( 'wp_enqueue_scripts', 'wp_guru_enque' );

About Author

I am Robin - WordPress Developer based in Sydney. I work as Digital Developer. I do some projects now and then, and love blogging about WordPress and Web Design.