【问题标题】:How can i fix a Mimetype error when uploading a stylesheet to wordpress?将样式表上传到 wordpress 时如何修复 Mimetype 错误?
【发布时间】:2020-03-24 11:10:47
【问题描述】:

我的 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


*/

我的函数.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 错误?

【问题讨论】:

    标签: php css wordpress ftp enqueue


    【解决方案1】:

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

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

    【讨论】:

    • 谢谢,我没有意识到。
    猜你喜欢
    • 2019-02-04
    • 2021-08-22
    • 2016-10-02
    • 2020-08-05
    • 1970-01-01
    • 2016-05-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多