我从夜莺主题中创建了一个子主题,但是当我试图在nigthingale- child /style.css中更改propetry时,它就不适用了。例如,我试图更改主体的背景色,或者不为h1标记显示任何颜色,只是为了查看我的子主题style.css是否工作,但什么也没有发生。
我遵循了创建子主题的所有步骤:-new文件夹,夜莺-子-inside,我添加了两个文件: function.php & style.css,这里是my style.css:
/*
Theme Name: nightingale-child
Theme URI: http://example.com/twenty-fifteen-child/
Description: nightingale Child Theme
Author: John Doe
Author URI: http://example.com
Template: nightingale
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
Text Domain: nightingalechild
*/
a {
color: red;
}这是我的function.php:
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
function enqueue_parent_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}有人知道我的夜莺儿童主题有什么问题吗?
发布于 2020-05-29 21:18:05
您的函数正在加载父主题CSS。您需要更改一些东西来加载子CSS:
<?php
// Let's change this to `enqueue_child_styles` so it's clearer.
add_action( 'wp_enqueue_scripts', 'enqueue_child_styles' );
// Now the function
function enqueue_child_styles() {
// Rename the hook to child-style
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri().'/style.css' );
}在这个实例中,您希望使用get_stylesheet_directory_uri(),因为get_template_directory_uri()总是指向父主题,在父主题中,get_stylesheet_directory_uri()指向子主题。
https://stackoverflow.com/questions/62094446
复制相似问题