【问题标题】:Wordpress child theme stylesheet doesn't seem to workWordpress 子主题样式表似乎不起作用
【发布时间】:2013-10-05 13:54:04
【问题描述】:

我已经为我想要更改的主题创建了一个子主题,但我在 style.css 中所做的更改并未显示在网站上。

这是我的 style.css 中的内容

/*
 Theme Name:     Soundstage Child Theme
 Description:    Soundstage Child Theme
 Author:         xxxxx
 Template:       soundstage
 Version:        1.0.0
*/

/* =Imports styles from the parent theme
-------------------------------------------------------------- */
@import url('../soundstage/style.css');


/* =Theme customization starts here
-------------------------------------------------------------- */

.logotext {
    font-family: "Life Savers", cursive; 
    font-weight:400; 
    position:relative; 
    top:12px;
    right:90px;
    }

.menu-item {
    font: 18px/20px cutive,Arial,Helvetica,Sans-Serif;
    }

只是为了检查一下,我安装了一个插件来添加额外的 CSS - 这个 CSS 在那里工作正常。

编辑:顺便说一下,子主题目录中的模板工作正常。

EDIT2:我刚刚注意到 WP 在调用样式表时带有一个参数(当前的 WP 版本),但我不太确定它来自哪里,或者如果我用 ver 查看样式表为什么不同= 开和关。:

<link rel='stylesheet' id='soundstage-css' href='http://domain.com/wp-content/themes/soundstage-child/style.css?ver=3.6.1' type='text/css' media='all'/>

【问题讨论】:

    标签: css wordpress


    【解决方案1】:

    查询字符串来自 WordPress 将脚本排入队列(然后打印)的方式。默认情况下,它会将 WordPress 版本打印为查询字符串中的版本(对你来说是最新的)。这样做是为了防止在文件更改时进行缓存。

    通常,无论查询字符串如何,css 的输出都不应更改。当这种情况发生时,首先要查看的是您的.htaccess 文件(位于您安装 WordPress 的目录的根目录中)。 WordPress' default .htaccess rules 应该没问题,但是如果您可能有其他规则,则可能是他们的错。

    虽然它不是永久修复,但添加以下.htaccess 指令(在文件顶部)将允许您解决问题:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^wp-content/themes/soundstage-child/style\.css$ - [L]
    </IfModule>
    

    如果错误停止,则 .htaccess 文件中的另一个指令导致 style.cssstyle.css?v=3.6.1 的奇怪行为。

    【讨论】:

    • 这行得通。谢谢你。这是 WP-supercache 放入 .htaccess 的内容。由于我决定不使用该插件,因此我将其全部删除。
    【解决方案2】:

    并非所有 wordpress 主题都支持子主题。 您可以使用 Jetpack 中包含的自定义 css 功能,也可以使用 wordpress 插件目录中的自定义 css plugin

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-13
      • 2016-12-08
      • 2013-07-13
      • 1970-01-01
      • 1970-01-01
      • 2016-02-01
      相关资源
      最近更新 更多