php - 将 CSS 连接到 wordpress 的子主题

标签 php html css wordpress

我的情况如下:我用 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/

相关文章:

php - javascript(jquery)中的组合树

php - 在提交到 git 之前自动更新内部版本号

javascript - 找到Phonegap使用的WebView?

javascript - 自动完成有问题

css - 表单中的下拉按钮

html - 单选按钮显示在标签中间

php - 我可以在 Woocommerce 电子邮件中按类别对订单商品进行排序吗

php - WordPress 自定义发布元 JSON 字符串不会用 json_decode() 解码

php - 验证错误/边界数据

jquery - 如何将 html 元素填充到另一个页面中?