Wordpress Snippets

Load CSS and JS the right way

/**
 * Load CSS and JS the right way
 *
 * @since  1.0
 * @refer  https://developer.wordpress.org/reference/functions/wp_enqueue_style/#comment-340
 */
function firerooster_load_css_and_js() {
  // Load Boostrap CSS
  wp_enqueue_style( 'bootstrap-css', get_template_directory_uri() . '/includes/bootstrap4/css/bootstrap.min.css' );
  
  // Load style.css
  wp_enqueue_style( 'style', get_stylesheet_uri() );
  
  // Load Boostrap JS
  wp_enqueue_script( 'bootstrap-js', get_stylesheet_directory_uri() . '/includes/bootstrap4/js/bootstrap.min.js', array('jquery'), '1.0', true);
}
add_action( 'wp_enqueue_scripts', 'firerooster_load_css_and_js' );

Hire Us. Or just say Hi!
Need a job? Apply to get one.