Before adding any file you must seperate your header.php
file & add wp_head()
function in header.php
file
// Load the theme stylesheets
function theme_styles()
{
// Example of loading a custom css file for homepage just on the homepage
wp_register_style( 'custom', get_template_directory_uri() . '/css/custom.css' );
if(is_page('home')) {
wp_enqueue_style('custom');
}
// Example of loading a main css file on all pages
wp_enqueue_style( 'main', get_template_directory_uri() . '/css/main.css' );
// Example of loading js files on all pages
wp_enqueue_script( 'scripts', get_template_directory_uri() . '/js/scripts.js');
}
add_action('wp_enqueue_scripts', 'theme_styles');
In this case the js files will be loaded on inside the <head></head>
tag. If you want to load the js files in ths bottom you must need to add <?php wp_footer() ?>
on your footer. And then you need to call the wp_enqueue_script()
this way.
wp_enqueue_script( 'scripts', get_template_directory_uri() . '/js/scripts.js','','1.1', true);
This true
boolean is the answer of the $in_footer
parameter of wp_enqueue_script()
function. ( See Doc )