php - Wordpress 子主题不会覆盖父主题 css
问题描述
我正在尝试为 Wordpress 主题二十七创建一个子主题。
我创建了一个名为twentyseventeen-child 的目录,并在其中创建了一个functions.php 和style.css 文件。
我无法弄清楚为什么我对子 style.css 所做的任何更改都没有实现。
这是我的孩子 style.css:
/*
Theme Name: Twenty Seventeen Child
Theme URL: http://tylerdevries.com
Description: Twenty Seventeen Child Theme
Author: Tyler DeVries
Author URL: http://tylerdevries.com
Template: twentyseventeen
Version: 1.0.0
Text Domain: twentyseventeen-child
*/
这是我的孩子 functions.php
<?php
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() .
'/style.css' );
}
?>
为了测试我的新子主题,我在我的子 style.css 中包含了以下代码
.site-content-contain {
background-color: #d5ffa0;
position: relative;
}
我还尝试了其他简单的 CSS 自定义 - 完全没有影响。
非常感谢对我做错的任何帮助。
解决方案
// Queue parent style followed by child/customized style
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles', PHP_INT_MAX);
function theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/styles/child-style.css', array( 'parent-style' ) );
}
推荐阅读
- sql - 如何修复 oracle ORA-01722 无效号码错误
- python - 无法正确拆分列表中的项目
- pandas - 如何在 dask 环境中使用 pd.groupby.transform 改进功能
- c++ - 我可以将 googletest 添加到现有的 Visual C++ 项目吗?
- php - 根据用户条件发送预定的电子邮件(Laravel)
- java - 如何为这个 Kotlin 类属性使用 setter?
- html - Beautifulsoup中的python find_all_next找不到字符串
- java - 十六进制编辑器,字节之间的空间
- biztalk - 备份 BizTalk 服务器 (BizTalkMgmtDb)
- row - 如何在 DOORS 中移动表格的一行?