Wordpress 子主题 CSS 个问题
Wordpress child theme CSS issues
我在 http://eventdepotnj.com 上使用 WooShop 主题并为其创建子主题。
我用这个 style.css 创建了一个新目录 /wooshop-child:
/*
Theme Name: WooShop Child
Description: Child theme for WooShop
Author: Blue Star Multimedia
Template: wooshop
*/
并且我使用以下代码添加了一个 functions.php 文件:
<?php
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
但是它不起作用。
我将我编辑的 header.php 和 footer.php 文件上传到子主题文件夹以覆盖常规主题,并且成功了。但是当我对 style.css 文件进行任何更改时,它并没有出现在我的子主题上,它似乎没有被拾取它。有什么想法吗?
您的服务器似乎正在缓存该文件。如果我将子样式表的 URL 从
更改为
http://eventdepotnj.com/wp-content/themes/wooshop-child/style.css?ver=4.1.1
至
http://eventdepotnj.com/wp-content/themes/wooshop-child/style.css?ver=4.1.2
(只是为了测试),我看到你在评论中提到的 20px 字体大小。检查 Chrome 的开发工具,我知道我没有看到本地缓存的版本 4.1.1 - 它来自您的服务器。
我建议根据文件修改时间自动生成您的版本号,以阻止它被缓存。详情见我的回答here。
我在 http://eventdepotnj.com 上使用 WooShop 主题并为其创建子主题。
我用这个 style.css 创建了一个新目录 /wooshop-child:
/*
Theme Name: WooShop Child
Description: Child theme for WooShop
Author: Blue Star Multimedia
Template: wooshop
*/
并且我使用以下代码添加了一个 functions.php 文件:
<?php
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
但是它不起作用。
我将我编辑的 header.php 和 footer.php 文件上传到子主题文件夹以覆盖常规主题,并且成功了。但是当我对 style.css 文件进行任何更改时,它并没有出现在我的子主题上,它似乎没有被拾取它。有什么想法吗?
您的服务器似乎正在缓存该文件。如果我将子样式表的 URL 从
更改为http://eventdepotnj.com/wp-content/themes/wooshop-child/style.css?ver=4.1.1
至
http://eventdepotnj.com/wp-content/themes/wooshop-child/style.css?ver=4.1.2
(只是为了测试),我看到你在评论中提到的 20px 字体大小。检查 Chrome 的开发工具,我知道我没有看到本地缓存的版本 4.1.1 - 它来自您的服务器。
我建议根据文件修改时间自动生成您的版本号,以阻止它被缓存。详情见我的回答here。