【问题标题】:Wordpress child theme CSS issuesWordpress 子主题 CSS 问题
【发布时间】:2015-04-08 23:28:31
【问题描述】:

我在 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 文件进行任何更改时,它并没有出现在我的子主题上,它似乎没有出现。有什么想法吗?

【问题讨论】:

  • 如果您直接浏览到您的样式表 (eventdepotnj.com/wp-content/themes/wooshop-child/…) 并刷新,您会看到您的代码吗?
  • 我看到那里的代码,但它不是最近更新的版本(我刚刚更新了 20px 的段落字体大小,看看它是否有效)

标签: css wordpress themes


【解决方案1】:

看起来您的服务器正在缓存文件。如果我将孩子的样式表的 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

【讨论】:

  • 看起来缓存是个问题——我在 GoDaddy 管理的 wordpress 上,他们做缓存。感谢您的帮助
  • 没问题;乐于助人
猜你喜欢
  • 1970-01-01
  • 2012-06-06
  • 2014-10-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-02-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多