我已成功为Emmet Lite template
, 使用上提供的信息here 和here
子主题的CSS文件如下所示:
/*
Theme name: Emmet Child
Theme URI: http://www.example.com/
Description: This is a child of Emmet Lite theme
Author: Motopress
Author URI: http://www.getmotopress.com/
Template: emmet-lite
Version: 1.0
*/
/* Adjustments to the Emmet Lite template start here */
.top-header {
display: none;
}
.site-header {
background-color: #FFC421;
}
我首先添加了@import
功能,但这对我不起作用。我读到的是,父css加载在子css之后,因此最后一个css获胜。为了解决这个问题,我添加了functions.php
到我的子文件夹,并删除@import
. 如下所示:<?php
function my_theme_enqueue_styles() {
$parent_style = \'parent-style\';
wp_enqueue_style( $parent_style, get_template_directory_uri() . \'/style.css\' );
wp_enqueue_style( \'child-style\',
get_stylesheet_directory_uri() . \'/style.css\',
array( $parent_style )
);
}
add_action( \'wp_enqueue_scripts\', \'my_theme_enqueue_styles\' );
?>
所以一切都正常运行,我在style.css
在我的网站上正确应用了子文件夹的。Understanding the situation:
我的问题是:家长Emmet
主题使用不同于style.css
. 此模板使用的名称是。。。
埃米特风格。min.css
它还包括Woocommerce、Buddypress和Bootstrap的一组其他样式,但我用于编辑的唯一文件是emmet样式。最小css。
我想知道我在这里做什么,即使它已经起作用了。我不喜欢PHP,所以从我的理解来看,这行代码调用了错误的CSS,但仍然有效?
wp_enqueue_style( $parent_style, get_template_directory_uri() . \'/style.css\' );
风格。css应该是emmet-style.min.css
还是总是这样style.css
不管怎样?在开发functions.php
其中提到要更改style.css
指向正确CSS路径的路径。所以我可能误解了这里的PHP。有人能帮我更深入地解释一下functions.php
对于子主题和给定的路径?