Wordpress 子主题样式表似乎不起作用 [英] Wordpress child theme stylesheet doesn't seem to work

查看:46
本文介绍了Wordpress 子主题样式表似乎不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为要更改的主题创建了一个子主题,但我在 style.css 中所做的更改没有显示在网站上.

I've created a child theme for the one I want to make changes on, but changes I make in style.css don't show up on the site.

这是我的 style.css 中的内容

Here's what's in my 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 在那里运行良好.

Just to check, I installed a plugin to add extra CSS — and this CSS works fine in there.

顺便说一下,子主题目录中的模板工作正常.

By the way, templates in the child theme directory work fine.

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

I just noticed WP is calling the stylesheet with a parameter after it (the current WP version), but I'm not quite sure where it's coming from or why the stylesheet is different if I look at it with the ver= on and off.:

<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'/>

推荐答案

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

The query string is coming from the way WordPress enqueues (and then prints) scripts. By default it will print the WordPress version as the version in the query string (good on you for being up to date). It does this in an effort to prevent cacheing when there are file changes.

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

Generally, the output of your css should not change, regardless of query string. When this occurs often the first place to look is your .htaccess file (found in the root of the directory where you have installed WordPress). WordPress' default .htaccess rules should be fine, but if you may have other rules, they may be to blame.

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

Although, it is not a permanent fix, adding the following .htaccess directive (at the top of the file), will allow you to troubleshoot the problem:

<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.

If the error stops, then another directive in your .htaccess file is causing the strange behavior of style.css vs. style.css?v=3.6.1.

这篇关于Wordpress 子主题样式表似乎不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆