php - wordpress function.php 不加载 css 样式表

标签 php css wordpress

我已经尝试了几个小时让 wp_enqueue_style 在头部加载时运行。

这是我的代码

function test_script(){

//Add Bootstrap Style
wp_enqueue_style('muarif-bootstrap',get_template_directory_uri().'/inc/css/bootstrap.css');

}
add_action('wp_enqueue_scripts','test_script');

但是当我运行我的网站时,它无法正确加载。

这是我生成的头像

<head>
     <title>Muarif Gustiar | Web Developer - User Experience - Digital Marketing</title>
     <meta charset="UTF-8">
     <meta name="description" content="">
     <meta name="viewport" content="width=device-width,initial-scale=1.0">
     <meta http-equiv="content-type" content="text/html; charset=UTF-8">
     <style type="text/css"></style>
</head>

我的代码有什么问题?我按照说明排队 here . 有什么建议吗?

最佳答案

以前给这个

function test_script(){

wp_register_style("bootstrapcss", get_template_directory_uri() . "/inc/css/bootstrap.css");

wp_enqueue_style('bootstrapcss'); 

}

add_action('wp_enqueue_scripts','test_script');

关于php - wordpress function.php 不加载 css 样式表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28978360/

相关文章:

javascript - 使用 CSS 或其他非 JS 方法模仿 "onselectstart=return false"?

php - 如何垂直对齐不在同一个 div 中的两个对象

php - 使用 jQuery 表单验证远程方法验证上传的文件大小

php - 在一列中显示多行 Mysql 和 PHP

php - 网站需要包含 index.php 的基本 url 才能正常工作

jquery - 输入字段调整大小,文本在一定长度后蠕变

css3 自动浏览器兼容性修复程序

php - 合并来自两个不同数据集的数据(Facebook 和 MySQL)

jquery - 使用循环为每个唯一的 id 设置不同的悬停背景

php - 样式化 Wordpress 错误页面