【问题标题】:Why isn't my child theme using the new style.css file?为什么我的子主题不使用新的 style.css 文件?
【发布时间】:2015-10-27 14:09:05
【问题描述】:

我遵循了一个关于如何将子主题加入队列的非常简单的教程,但是当我真正去编辑我的 style.css 时,没有任何转移。我是否使用了错误的 given 代码?

style.css

/*
Theme Name: Blank Slate Child
Theme URI: http://www.efficientmind.org/blankslate-child/

*/

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' );

}

?>

【问题讨论】:

  • 我不明白...你是说编辑子主题 style.css 时什么都没有发生吗?
  • @rnevius 没错。我添加了代码以尝试修改我的元素之一,但什么也没发生。
  • 我现在正在阅读another tutorial,它说我需要“注册”我的孩子主题 style.css ......但另一个没有提到这一点!这有多重要?

标签: php html css wordpress


【解决方案1】:

您的子主题样式表标题需要包含模板行(父主题名称)才能正常工作。

codex | child themes

例子:

/*
Theme Name:     Twenty Thirteen Child
Theme URI:      http://example.com/
Description:    Child theme for the Twenty Thirteen theme
Author:         Your name here
Author URI:     http://example.com/about/
Template:       twentythirteen
Version:        0.1.0
*/

【讨论】:

    【解决方案2】:

    在您的子主题的 style.css 文件中添加以下注释:

    Template: BlankSlate
    

    您的新 Style.css 应如下所示:

    /*
    Theme Name: Blank Slate Child
    Theme URI: http://www.efficientmind.org/blankslate-child/
    Template: BlankSlate
    */
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-04
      • 2021-01-16
      • 2017-02-19
      • 2018-10-16
      • 1970-01-01
      • 1970-01-01
      • 2018-03-24
      相关资源
      最近更新 更多