我按照所有说明创建了我的子主题。在functions.php中,我有:
<?php
add_action( 'wp_enqueue_scripts', 'tt_child_enqueue_parent_styles' );
function tt_child_enqueue_parent_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
?>
在 style.css 中,我有正确的标题注释部分:
/*
Theme Name: Twenty Twenty Child
Theme URI: http://example.com/twenty-twenty-child/
Description: Twenty Twenty Child Theme
Author: X Y
Author URI: http://example.com
Template: twentytwenty
Version: 1.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: twentytwentychild
*/
h1 {
visibility: hidden;
}
但是,似乎孩子 style.css 不起作用,没有效果。在页面 HTML 代码中,以下行显示并看起来正确:
<link rel='stylesheet' id='parent-style-css' href='https://lifepromise.co.uk/wp-content/themes/twentytwenty/style.css' media='all' />
<link rel='stylesheet' id='twentytwenty-style-css' href='https://lifepromise.co.uk/wp-content/themes/twentytwenty-child/style.css' media='all' />