enqueue_stylesheet,但不适用于wordpress主题开发

问题描述

我最近下载了一个主题,并尝试将其转换为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;
}

这是我的文件夹结构

enter image description here

在资产文件夹中

enter image description here

这是我主题的样子

enter image description here

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

有人请帮我 预先谢谢你

解决方法

据我所见,这些代码片段应该都可以正常工作。但是,看来您的functions.php被称为function.php(不带“ s”),导致Wordpress忽略了该文件。希望重命名文件可以解决您的问题!