自定义 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>

我错过了什么/做错了什么?


茅侃侃
浏览 139回答 1
1回答

白板的微信

你的wp_enqueue_script我认为有错误。wp_enqueue_style('customstyle',&nbsp;get_template_directory_uri()&nbsp;.&nbsp;'css/awesome.css',&nbsp;array(),&nbsp;'1.0.0',&nbsp;'all')把上面的改成&nbsp;wp_enqueue_style('customstyle',&nbsp;get_template_directory_uri()&nbsp;.&nbsp;'/css/awesome.css',&nbsp;array(),&nbsp;'1.0.0',&nbsp;'all')这是因为get_template_directory_uri()指向您的主题的路径。在这里,http:/ /placeholder-url.net/wp-content/themes/awesometheme为了将其指向 css 文件夹中的样式表,您需要添加/css/awesome.css.
打开App,查看更多内容
随时随地看视频慕课网APP