自定义WordPress样式表未加载

我讨论了有关该主题的许多其他主题, 但是似乎没有一个适合我。

我正在尝试制作自己的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


我认为你的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。

来源:

https://www.srcmini02.com/62436.html

微信公众号
手机浏览(小程序)
0
分享到:
没有账号? 忘记密码?