0

我最近下载了一个主题并尝试将其转换为 wordpress 主题。

现在我陷入了错误,我试图将我的样式表脚本排入主题并且它不起作用。

这是我的标题,我使用 wp_head() 标记来挂钩我的入队函数

<!DOCTYPE html>
<html dir="ltr" lang="en-US">

<head>

  <meta http-equiv="content-type" content="text/html; charset=utf-8" />

  <meta name="viewport" content="width=device-width, initial-scale=1" />

  <!-- Document Title
    ============================================= -->
  <title>Index Template</title>
  <!-- <link rel="stylesheet" href="" type="text/css" /> -->
  <?php wp_head(); ?>

</head>

这是我的加载样式表函数代码,add_action 函数用于将函数挂钩到标题

function ft_loadScripts()
{
    wp_register_style( 'ft_style', get_stylesheet_uri() );
    wp_enqueue_style( 'ft_style' );
}

add_action( 'wp_enqueue_scripts','ft_loadScripts' );

这是我为主题创建的主要样式表,它
位于此样式表的主题文件夹中,我仅使用正文背景颜色来测试代码。

/*
Theme Name: Firstweb
Theme URI: https://wordpress.org/themes/Firstweb/
Author:John don
Author URI: https://wordpress.org/
Description: Our default theme for 2020 is designed to take full advantage of the flexibility of the block editor. Organizations and businesses have the ability to create dynamic landing pages with endless layouts using the group and column blocks. The centered content column and fine-tuned typography also makes it perfect for traditional blogs. Complete editor styles give you a good idea of what your content will look like, even before you publish. You can give your site a personal touch by changing the background colors and the accent color in the Customizer. The colors of all elements on your site are automatically calculated based on the colors you pick, ensuring a high, accessible color contrast for your visitors.
Version: 1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: Firstweb
*/

body{
    background-color: black;
}

这是我的文件夹结构

在此处输入图像描述

在资产文件夹中

在此处输入图像描述

这就是我的主题的样子

在此处输入图像描述

但我不知道为什么它不起作用。我还检查了开发人员工具,控制台中没有样式表错误,但样式表仍然无法正常工作

有人请帮我提前谢谢你

4

1 回答 1

0

据我所知,代码片段应该都可以正常工作。但是,看起来你的functions.php被调用function.php(没有's'),导致 Wordpress 忽略该文件。希望重命名文件可以解决您的问题!

于 2020-09-06T08:17:21.017 回答