【发布时间】:2019-10-19 10:39:23
【问题描述】:
我是 wordpress 开发的新手。我正在学习开发一个新主题。我知道,对于 wordpress 主题,基本只有两个绝对必要的文件。为了测试,我创建了一个 index.php 文件和 style.css 字段,并尝试将其用作主题。但我在做这件事时遇到了问题。
正在读取 index.php 文件并在主页上显示内容,但没有从 style.css 文件中加载 css。正在阅读第一条评论,因为可以在主题详细信息部分看到主题信息,但未加载 css。
我遇到两种错误,首先
“加载资源失败:服务器响应状态为 404(未找到)” 参考图片:
而且, “GET http://rockstargaming.hol.es/style.css net::ERR_ABORTED 404(未找到)”
起初我试图通过<link> 标记包含样式表,但在收到错误后我尝试了另一种将脚本排入队列的方法 - 通过 funstions.php 文件,但后来我什么也没看到,没有错误也没有样式。
似乎没有任何效果,我尝试了多次。
index.php:-
<!doctype HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Gym</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div>
Testing theme development
</div>
<div class="top-ribbon top-ribbon-left"></div>
<div class="top-ribbon top-ribbon-right"></div>
</body>
</html>
style.css
/*
Theme Name: GymTheme
Author: SamarpitShrivastava
Author URI: https://www.google.com
Version: 1.0
*/
html,body{
margin: 0;
padding: 0;
font-size: 10px;
background-color: #1f1f1f;
}
/*Upper Ribbon*/
/*Phone*/
.top-ribbon-left{
background-image: linear-gradient(45deg, #ffd900, #ffb700);
width: 81%;
height: 13em;
float: left;
position: absolute;
margin-left: -3em;
transform: rotateZ(-10deg);
z-index: 1;
box-shadow: 0 0 5 5 yellow;
}
.top-ribbon-right{
border-top: 18em solid #ffb700;
width: 0;
height: 0;
border-left: 35em solid transparent;
float: right;
position: absolute;
right: 1em;
margin-right: -3em;
margin-top: -0.5em;
transform: rotateZ(6deg);
z-index: 200;
}
/*Phone*/
/*Tablet*/
@media only screen and (min-width: 800px){
/* For Tablets: */
.top-ribbon-left{
background-image: linear-gradient(45deg, #ffd900, #ffb700);
width: 80%;
height: 17em;
float: left;
position: absolute;
margin-left: -3em;
transform: rotateZ(-10deg);
z-index: 1;
}
.top-ribbon-right{
border-top: 25em solid #ffb700;
width: 0;
height: 0;
border-left: 49em solid transparent;
float: right;
position: absolute;
right: 1em;
margin-right: -3em;
margin-top: -1em;
transform: rotateZ(6deg);
z-index: 200;
}
}
/*Tablet*/
/*Desktop*/
@media only screen and (min-width: 1300px) {
/* For desktop: */
.top-ribbon-left{
background-image: linear-gradient(45deg, #ffd900, #ffb700);
width: 80%;
height: 20em;
float: left;
position: absolute;
margin-left: -3em;
transform: rotateZ(-10deg);
z-index: 1;
}
.top-ribbon-right{
border-top: 30em solid #ffb700;
width: 0;
height: 0;
border-left: 60em solid transparent;
float: right;
position: absolute;
right: 1em;
margin-right: -3em;
margin-top: 0em;
transform: rotateZ(6deg);
z-index: 200;
}
}
/*Desktop*/
/*Upper Ribbon*/
functions.php
<?php
function includeResources(){
wp_enqueue_style('style', get_stylesheet_uri());
}
add_action('wp_enqueue_scripts', 'includeResources');
?>
【问题讨论】:
-
你有一个错字:“function inculdeResources()”
标签: php css wordpress wordpress-theming