如果只引入style.css,我把這個放頭頂就可以了
<link rel="stylesheet" href="<?php echo get_stylesheet_uri(); ?>" type="text/css" media="screen" />
再加其他樣式,那就加多一個這個在頭頂
<link rel="stylesheet" href="<?php echo get_template_directory_uri();?>/bootstrap.min.css">
另外一種推薦的方法:
把下面的方法加到functions.php
/** * 加載前台腳本和樣式表 * 加載主樣式表style.css */ add_action('wp_enqueue_scripts', 'my_scripts'); function my_scripts() { //加載主題中的style.css wp_enqueue_style('global', get_stylesheet_uri());
//加載css文件夾中的xx.css樣式 wp_enqueue_style('index-style', get_template_directory_uri().'/css/xx.css');
//同理加載js文件夾中的xx.js
wp_enqueue_script('index-js', get_template_directory_uri().'/js/xx.js');
//加載tool.js前加載默認jquery庫
wp_enqueue_script('lingfeng-lazy',get_template_directory_uri().'/js/tool.js',array('jquery'));
}
然后在head里加上這個就會自動引入樣式噢~
<?php wp_head();?>