I try to load the main stylesheet with enqueue_style – but it isn’t working.
Here is my code from functions.php:
function my_scripts() {
wp_enqueue_style( 'main-style', get_template_directory_uri() . '/style.css', false, '1.0', 'all' );
}
add_action( 'wp_enqueue_scripts', 'my_scripts' );
Loading the stylesheet in the header.php by using a link-tag works fine.
I can’t find the error – it seems that code is ignored – but function.php is loading.
I also tried to use get_template_directory_uri()
instead of get_template_directory_uri()
.
Because it is the recommended way to link to styles and scripts I want to get this work. I also want to use enqueue_scripts for some js and jQuery scripts.
Thanks for any hint or advice
The solution: I forgot to call wp_head() in the header.php – added and everything works 🙂
The solution: I forgot to call wp_head() in the header.php – added and everything works 🙂
get_template_directory_uri()
has no trailing slash.From Codex:
Use
get_template_directory_uri() . '/style.css'
and it will works (it should…).Update your code to bellow:
Note:
get_template_directory_uri()
has no trailing slash(/).Whenever you have error related to css or js file loading first check in developer tools like firebug whether the link or script tags for css or js respectively loaded or not if loaded then get the url from there and execute in browser if coding coming then ok or else correct the path then change the same in code accordingly.
I don’t have reputation to comment. This may work Try script for style too. Like this
or
try