0

我的 CSS

/*
Theme Name: Data Kraken
Theme URI: https://wordpress.com/themes/d-k/
Description: With bold featured images and bright, cheerful colors, Dara is ready to get to work for your business.
Version: 1.0.0
Author: Automattic
Author URI: http://wordpress.com/themes/
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: d-k


*/

我的functions.php

<?php 
    function enqueue_kraken_theme(){

        //style
        wp_enqueue_style( 
            "custom",
            get_template_directory(  ) . "/style.css",
            array(),
            "1.0.0",
            "all"
        );


    }

    add_action("wp_enqueue_scripts", "enqueue_kraken_theme");



目前我正在尝试将样式表 style.css 排入队列,但我不断收到错误消息

Refused to apply style from 
because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

我不确定发生了什么,因为我正在尝试上传 style.css 文件。

将样式表上传到 wordpress 时如何修复 Mimetype 错误?

4

1 回答 1

0

您正在使用 get_template_directory(),它返回目录的绝对路径。你应该使用 get_template_directory_uri() 即

wp_enqueue_style("custom", get_template_directory_uri() . "/style.css", array(), "1.0.0", "all");
于 2020-03-24T22:15:59.310 回答