将样式表上传到 wordpress 时如何修复 Mimetype 错误?
How can i fix a Mimetype error when uploading a stylesheet to wordpress?
我的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");
目前我正在尝试将样式入队 sheet 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 文件。
如何修复上传样式时的 Mimetype 错误sheet 到 wordpress?
您正在使用 get_template_directory(),其中 returns 是目录的绝对路径。
你应该使用 get_template_directory_uri() 即
wp_enqueue_style("custom", get_template_directory_uri() . "/style.css", array(), "1.0.0", "all");
我的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");
目前我正在尝试将样式入队 sheet 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 文件。
如何修复上传样式时的 Mimetype 错误sheet 到 wordpress?
您正在使用 get_template_directory(),其中 returns 是目录的绝对路径。 你应该使用 get_template_directory_uri() 即
wp_enqueue_style("custom", get_template_directory_uri() . "/style.css", array(), "1.0.0", "all");