[英]Custom WordPress stylesheet not loading
I went through the many other threads on this topic, but none of it seems to work for me. 我讨论了有关此主题的许多其他主题,但是似乎没有一个适合我。
I'm trying to make my own WordPress theme, but I keep getting this error: 我正在尝试制作自己的WordPress主题,但始终收到此错误:
GET http:/ /placeholder-url.net/wp-content/themes/awesomethemecss/awesome.css?ver=1.0.0 net::ERR_ABORTED 404 (Not Found)
Here's the php: 这是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');
That's my test CSS: 那是我的测试CSS:
html, body {
color: #333;
background: #eee;
font: sans-serif;
}
And the header.php: 和header.php:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Awesome Theme</title>
<?php wp_head();?>
</head>
<body>
What am I missing/doing wrong? 我想念/做错了什么?
There is an error on your wp_enqueue_script
i think. 我认为您的wp_enqueue_script
有一个错误。
wp_enqueue_style('customstyle', get_template_directory_uri() . 'css/awesome.css', array(), '1.0.0', 'all')
Change the above one to 将以上内容更改为
wp_enqueue_style('customstyle', get_template_directory_uri() . '/css/awesome.css', array(), '1.0.0', 'all')
This is because get_template_directory_uri()
points to the path to your theme. 这是因为get_template_directory_uri()
指向主题的路径。
Here it is, http:/ /placeholder-url.net/wp-content/themes/awesometheme
and inorder to point this to your stylesheet in css folder, you need to add /css/awesome.css
. 这里是http:/ /placeholder-url.net/wp-content/themes/awesometheme
,为了将其指向css文件夹中的样式表,您需要添加/css/awesome.css
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.