I've been reading Wordpress Theme Developer Handbook to learn how things work and try to practice according to what's written in there.
I've created my index.php, style.css, function.php and header and footer files. According to the Including CSS & JavaScript Part . it says that other than directly use the link tag, i need to create a functions.php and in to that file i need to add wp_enqueue_style( 'style', get_stylesheet_uri() );
function with these parameters.
I am adding this line of code to my functions.php but I can't see the file when I look at the source of the page.
I also tried to add this function to my header.php instead of functions.php , it doesn't seem to work.
I've been reading Wordpress Theme Developer Handbook to learn how things work and try to practice according to what's written in there.
I've created my index.php, style.css, function.php and header and footer files. According to the Including CSS & JavaScript Part . it says that other than directly use the link tag, i need to create a functions.php and in to that file i need to add wp_enqueue_style( 'style', get_stylesheet_uri() );
function with these parameters.
I am adding this line of code to my functions.php but I can't see the file when I look at the source of the page.
I also tried to add this function to my header.php instead of functions.php , it doesn't seem to work.
Share Improve this question edited Jul 21, 2019 at 0:25 fuxia♦ 107k39 gold badges255 silver badges459 bronze badges asked Jul 20, 2019 at 22:29 NoobDevNoobDev 132 bronze badges1 Answer
Reset to default 0Your call to wp_enqueue_style()
looks good and functions.php
is the right place, but your code should be wrapped inside a function attached to the wp_enqueue_scripts
hook. See the Combining Enqueue Functions section of the page you referenced for a full example. Generally speaking, any code you run in WordPress should be run on some hook or filter. Otherwise the code will be run as soon as the code is read which is usually not the correct time.
function mytheme_add_theme_scripts() {
wp_enqueue_style( 'style', get_stylesheet_uri() );
}
add_action( 'wp_enqueue_scripts', 'mytheme_add_theme_scripts' );
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745308845a4621876.html
评论列表(0条)