我瀏覽了有關(guān)此主題的許多其他主題,但似乎沒有一個對我有用。我正在嘗試制作自己的 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貢獻(xiàn)1883條經(jīng)驗(yàn) 獲得超3個贊
你的wp_enqueue_script
我認(rèn)為有錯誤。
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')
這是因?yàn)?code>get_template_directory_uri()指向您的主題的路徑。
在這里,http:/ /placeholder-url.net/wp-content/themes/awesometheme
為了將其指向 css 文件夾中的樣式表,您需要添加/css/awesome.css
.
- 1 回答
- 0 關(guān)注
- 168 瀏覽
添加回答
舉報(bào)
0/150
提交
取消