我的情况如下:我用 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
在你的主题中——这意味着你可以覆盖 parent 在 child 身上设置的任何规则。
/* child's default.css */
@import url (" /* path to parent's default.css */ ");
关于php - 将 CSS 连接到 wordpress 的子主题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40872509/