【发布时间】:2016-12-17 15:50:47
【问题描述】:
我有几个 css 文件需要链接到滑块、owl carousel 插件等的主 PHP 文件。
搜索后,我发现了如何在我的主题中添加多个 css:
1) 使用wp_register_style
2)使用wp_enqueue_style
我无法弄清楚它们之间的区别。我也想知道怎么用。
这是我将 HTML 主题转换为 Wordpress 之前的样式链接:
<link rel="stylesheet" type="text/css"
href="stylecss/bootstrap.min.rtl.css.css">
<link rel="stylesheet" type="text/css" href="stylecss/bootstrap-3.2.rtl.css">
<link rel="stylesheet" href="fa/css/font-awesome.min.css">
<link rel="stylesheet" href="owl-carousel/owl.carousel.css">
<link rel="stylesheet" href="owl-carousel/owl.theme.css">
<link rel="stylesheet" type="text/css" href="stylecss/style.css">
<link rel="stylesheet" type="text/css" href="font/stylesheet.css">
这是我尝试链接我的 css 文件的方式:
<!-- adding bootstrap style sheet -->
<?php wp_register_style('bootstrap-style1',get_template_directory_uri() . '/stylecss/bootstrap.min.rtl.css.css',array(),'null', 'all', );?>
<?php wp_register_style('bootstrap-style2',get_template_directory_uri() . '/stylecss/bootstrap-3.2.rtl.css',array(),'null', 'all', );
?>
<!-- End of bootstrap style links -->
<!-- adding fonts style sheet -->
<?php wp_register_style('font-awesome',get_template_directory_uri() . 'fa/css/font-awesome.min.css',array(),'null', 'all', );
?>
<?php wp_register_style('fonts',get_template_directory_uri() . 'font/stylesheet.css',array(),'null', 'all', );
?>
<!-- End of fonts style links -->
将此代码添加到function.php和header.php有什么区别?我读了here,我们可以在 header.php 和 function.php 中添加。
【问题讨论】:
标签: php jquery html css wordpress