Adding css and js in wp header and footer

In old version we can use “, still it is working but best way for theme development given bellow (specially for wordpress 4.8) :

Inside functions.php

<?php

/*<link rel="stylesheet" href="/css/path”>*/ // – another way to write css

// load css into the website’s front-end
function my_function_name() {

// Adding css
wp_register_style( ‘bootstrap’, get_template_directory_uri().
‘/css/bootstrap.min.css’, array(), ‘3.1.0’, ‘all’);

wp_register_style( ‘fancybox’, get_template_directory_uri().
‘/css/fancybox/jquery.fancybox.css’, array(), ‘3.1.0’, ‘all’);

wp_register_style( ‘flexslider’, get_template_directory_uri().
‘/css/flexslider.css’, array(), ‘3.1.0’, ‘all’);

wp_register_style( ‘style’, get_template_directory_uri().
‘/css/style.css’, array(), ‘1.0’, ‘all’);

wp_register_style( ‘skin’, get_template_directory_uri().
‘/skins/default.css’, array(), ‘1.0’, ‘all’);

wp_enqueue_style(‘bootstrap’);
wp_enqueue_style(‘fancybox’);
wp_enqueue_style(‘flexslider’);
wp_enqueue_style(‘style’);
wp_enqueue_style(‘skin’);

// Adding js
wp_enqueue_script(‘jquery’); // Adding default js

wp_enqueue_script(‘easing’, get_template_directory_uri().
‘/js/jquery.easing.1.3.js’, array(‘jquery’), ‘1.0’, true );
wp_enqueue_script(‘bootstrap-js’, get_template_directory_uri().
‘/js/bootstrap.min.js’, array(‘jquery’), ‘1.0’, true );

}
add_action( ‘wp_enqueue_scripts’, ‘my_function_name’ );

?>

Leave a Reply

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