gpt4 book ai didi

css - 在 WordPress 中创建子主题时遇到问题

转载 作者:太空宇宙 更新时间:2023-11-04 09:56:14 24 4
gpt4 key购买 nike

您好,我按照以下步骤操作: https://codex.wordpress.org/Child_Themes

仍然没有运气,主题激活正常,但父主题仍然保持完全激活。

样式.css: enter image description here

函数.php: enter image description here

文件位置和 WP 编辑器: enter image description here enter image description here

如有任何帮助,我们将不胜感激。同样,子主题似乎并没有覆盖父主题 dalton。

最佳答案

你不应该需要在你的子主题 CSS 中加入父主题的样式表 - 它应该已经加入队列(你可能会发现,如果你查看源代码,你只是有父主题的两个副本样式表到位)。

像这样排队你的子主题样式表:

add_action('wp_enqueue_scripts', 'my_the_enqueue_styles', 12); // Give this a lower priority so that it should be enqueued after the parent theme

function my_the_enqueue_styles() {
wp_enqueue_style('child-style', get_stylesheet_directory_uri() . '/style.css');
}

...然后,在您的子主题 CSS 中,添加一些明显的内容,例如:

body {
background-color: purple;
}

...您应该会看到子主题样式表与您的父主题元素一起加载。

值得注意的是,get_template_directory_uri() 将始终引用父主题,而 get_stylesheet_directory_uri() 将始终引用当前事件的子主题。如果没有子/父主题并且您使用的是常规独立主题,则可以交替使用这些命令。

关于css - 在 WordPress 中创建子主题时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38701855/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com