Reputation: 31
I have a wordpress
local installation and I am trying to load scripts and styles with wp_enqueue
but none of these are working, the front-end is not capturing any of the files,
Here is the code:
<?php
function all_the_scripts() {
wp_enqueue_style( 'style', get_stylesheet_uri() );
wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/assets/css/bootstrap.css' );
wp_enqueue_style( 'custom', get_template_directory_uri() . '/assets/css/custom.css' );
wp_enqueue_script( 'bootstrap.bundle', get_template_directory_uri() . '/assets/js/bootstrap.bundle.js' , array ( 'jquery' ) );
wp_enqueue_script( 'custom-scripts', get_template_directory_uri() . '/assets/js/custom-scripts.js', array ( 'jquery' ) );
}
add_action( 'wp_enqueue_scripts', 'all_the_scripts' );
?>
I have double checked everything, all the files are in the correct locations and all required arguments are given, but still no result.
I tried wp_register_script
but they say that it is optional and not needed
Upvotes: 3
Views: 271
Reputation: 1525
Use
get_stylesheet_directory_uri()
instead of
get_template_directory_uri()
The get_template_directory_uri()
reference to the parent theme if you're developing Child Themes, and get_stylesheet_directory_uri()
returns the URI of the current theme.
Upvotes: 2