I’m new to WordPress. I’m including my file using
<link rel="stylesheet" href="https://wordpress.stackexchange.com/questions/236370/<?php bloginfo("stylesheet_url")?>"/>
But if i enqueue my css file in functions.php
it is not working. Why?
Where is my mistake?
<?php wp_enqueue_style('style',get_template_directory_uri())?>
What is the solution for this?
2 Answers
You are calling the function wrong. You have not given your filename, just a directory.
From the codex
wp_enqueue_style( string $handle, string $src = false, array $deps = array(), string|bool|null $ver = false, string $media="all" )
so in your case, you should enqueue like so
add_action( 'wp_enqueue_scripts', 'wpse_my_style' );
function wpse_my_style(){
wp_enqueue_style( 'my-style', get_stylesheet_directory_uri() . 'path/to/your/css' );
}
the rest of the parameters are optional