我的情况如下:我用functions.php和以下代码创建了一个wordpress的子主题(它工作):
add_action( 'wp_enqueue_scripts', 'enqueue_parent_theme_style');
function enqueue_parent_theme_style() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
主题子中 style.css 的代码我使用了以下代码(有效):
/*
Theme Name: Enigma Child
Theme URI: http://weblizar.com/themes/enigma/
Description: Tema child per il tema enigma
Author: Carlo
Author URI: http://weblizar.com/
Template: enigma
Version: 2.7
*/
对于所有其他 CSS 例如:
default.css (father theme)
它位于父主题中。子主题如何覆盖规则
default.css (chile-theme)
更新父亲主题后不丢失任何变化。
感谢您的回答
最佳答案
您可以在子主题的 default.css
顶部导入父主题的 default.css
然后只引用子主题的 default.css
在您的主题中 - 这意味着您可以覆盖父在子中设置的任何规则。
/* child's default.css */
@import url (" /* path to parent's default.css */ ");
关于php - 将 CSS 连接到 wordpress 的子主题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40872509/