php - Style.css 不适用于我的自定义 wordpress 主题
问题描述
我是 wordpress 的新手,我知道有很多关于我的问题的答案,但是,即使我已经尝试了很多,但无论我做什么,它仍然无法正常工作。
我已经制作了自己的自定义 wordpress 主题,它使用引导外部链接样式工作,但我自己的 style.css 不适用。只是为了确保我已经将它包含在我的 header.php 中。我使用本教程将其转换为 html-sites-to-wordpress-sites
这是我的 header.php
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>walabi</title>
<!-- Font Awesome -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css">
<link href="https://fonts.googleapis.com/css?family=Niconne&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Nunito&display=swap" rel="stylesheet">
<!-- Custom CSS -->
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url');?>css/style.css">
<!-- Bootstrap core CSS -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
<!-- Material Design Bootstrap -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.8.7/css/mdb.min.css" rel="stylesheet">
<!-- Cache Control -->
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<meta http-equiv="refresh" content="600">
</head>
<body>
<!-- Header Start -->
<nav id="paham-nav" class="navbar navbar-expand-lg fixed-top scrolling-navbar">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo02" aria-controls="navbarTogglerDemo02" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"><i class="fas fa-chevron-down" style="color: aliceblue"></i></span>
</button>
<div class="collapse navbar-collapse" id="navbarTogglerDemo02">
<ul class="navbar-nav ml-auto nav-flex-icons">
<li class="nav-item">
<a class="nav-link" href="index.php">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="career.php">Career</a>
</li>
</ul>
</div>
</nav>
<!-- Header End -->
这是我的function.php(首先这个function.php是如何工作的?当我什至没有声明它时)
<?php
//Definir le répertoire du thème
define("THEME_DIR", get_template_directory_uri());
//Enlever le générateur de tags meta pour la sécurité (les gents ne peuvent pas voir quelle version WP)
remove_action('wp_head', 'wp_generator');
// ENQUEUE STYLES
function enqueue_styles() {
/* Main CSS */
wp_register_style( 'style', THEME_DIR . '/style.css', array(), '1', 'all');
wp_enqueue_style( 'style' );
}
add_action( 'wp_enqueue_scripts', 'enqueue_styles' );
?>
这是我尝试的一些答案:
样式-css-in-wordpress-doesnt-work-after-adding-header-php-file
样式-css-not-loading-in-wordpress-theme
样式-css-not-working-in-wordpress
只是为了确保这是我的目录:
在我的目录中有:
- 职业生涯.php
- 页脚.php
- 头文件.php
- 索引.php
- 函数.php
- 截图.png
- 样式.css
有人可以帮我解决这个问题吗?从昨天开始我仍然无法解决这个问题
解决方案
您是否尝试过回应 bloginfo('stylesheet_url') ?也许该函数没有返回任何内容或错误的路径。
为了测试,你也可以将css文件的路径直接放在HTML上。
<!-- Custom CSS -->
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url');?>css/style.css">
<!-- Custom CSS -->
<link rel="stylesheet" href="PATH_TO_CUSTOM_CSS/css/style.css">
推荐阅读
- github - GitHub 提交守门人
- java - 在目标之前在 Java Eclipse Maven 中执行 jar
- typescript - 如何使用 ng-2 智能表在创建和编辑时自动完成
- laravel - Laravel Auth 重置密码功能视图不起作用
- php - MySQL查询无结果
- abap - 有没有办法检查 RFC 是否存在于 SAP 系统中
- ios - 在 swift (iOS) 中的文本字段内添加前缀
- javascript - 将字符串转换为日期而不考虑时区
- kubernetes - OpenEBS 是否支持 Jiva Volumes 的 ReadOnlyMany 选项?
- php - 使用 PHP 使用包含电子邮件地址的查询字符串验证 url