【问题标题】:WordPress Child Theme Styles Not Being Applied未应用 WordPress 子主题样式
【发布时间】:2019-01-18 08:18:15
【问题描述】:

我正在使用 Ocean-WP 子主题。我已经在子主题中创建了一个样式表,因为我知道不要向父样式表添加样式。问题是没有应用我在子样式表中编写的样式。 为什么?

/*
Theme Name: OceanWP Child
Theme URI: https://oceanwp.org/
Description: OceanWP WordPress theme example child theme.
Author: 
Author URI: https://oceanwp.org/
Template: oceanwp
Version: 1.0
*/

@import url("../oceanwp/style.css");
form{
    background-color:blue !important;
}

@media only screen and (min-device-width : 320px) and (max-device-width : 374px){
#page-title{
    font-size:3.5rem;
}

}

【问题讨论】:

  • 为什么不试试github.com/oceanwp/oceanwp-child-theme 提供的他们自己的儿童主题。删除您当前的子主题,上传并激活他们的子主题,并将您的样式放入新子主题的style.css 文件中。请注意,您不需要在子主题中使用@import url("../oceanwp/style.css");

标签: wordpress wordpress-theming media-queries


【解决方案1】:

从浏览器的“查看源代码”中查找 css 名称。搜索 style.css 并找出名称。现在将下面的代码添加到您的 functions.php 文件中。 由于查询字符串,wordpress 不显示更新的子主题 css 的原因。您需要做的就是使用以下代码更改查询字符串版本并清除浏览器缓存。享受吧。

function update-child-css() {
wp_enqueue_style('child-theme-css-name', get_stylesheet_directory_uri() .'/style.css', array(), '1.0.1' );
}
add_action('wp_enqueue_scripts', 'update-child-css');

【讨论】:

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