为了账号安全,请及时绑定邮箱和手机立即绑定

自定义 WordPress 样式表未加载

自定义 WordPress 样式表未加载

PHP
茅侃侃 2021-11-26 16:44:05
我浏览了有关此主题的许多其他主题,但似乎没有一个对我有用。我正在尝试制作自己的 WordPress 主题,但我不断收到此错误:GET http:/ /placeholder-url.net/wp-content/themes/awesomethemecss/awesome.css?ver=1.0.0 net::ERR_ABORTED 404 (Not Found)这是php:function load_my_stylesheets() { wp_enqueue_style('customstyle', get_template_directory_uri() . 'css/awesome.css', array(), '1.0.0', 'all'); }add_action('wp_enqueue_scripts', 'load_my_stylesheets');这是我的测试 CSS:html, body {    color: #333;    background: #eee;    font: sans-serif;}和 header.php:<!doctype html><html><head>    <meta charset="utf-8">    <title>Awesome Theme</title>    <?php wp_head();?></head><body>我错过了什么/做错了什么?
查看完整描述

1 回答

?
白板的微信

TA贡献1883条经验 获得超3个赞

你的wp_enqueue_script我认为有错误。

wp_enqueue_style('customstyle', get_template_directory_uri() . 'css/awesome.css', array(), '1.0.0', 'all')

把上面的改成

 wp_enqueue_style('customstyle', get_template_directory_uri() . '/css/awesome.css', array(), '1.0.0', 'all')

这是因为get_template_directory_uri()指向您的主题的路径。

在这里,http:/ /placeholder-url.net/wp-content/themes/awesometheme为了将其指向 css 文件夹中的样式表,您需要添加/css/awesome.css.


查看完整回答
反对 回复 2021-11-26
  • 1 回答
  • 0 关注
  • 137 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信