0
我在wordpress中创建了一个名为bigpont的父主题的子主题。我也在网站上使用woocommerce。我已经征服了我的孩子主题样式表,并且注意到它加载了两次,我不知道为什么。我也想知道如何让它加载,以覆盖woocommerce样式表。这是我目前使用在我functions.php文件中的代码:enqueing stylesheet for a child theme in wordpress
function my_theme_enqueue_styles() {
$parent_style = 'bigpoint-css';
wp_enqueue_style($parent_style, get_template_directory_uri() . '/base.css');
wp_enqueue_style('child-style',
get_stylesheet_directory_uri() . '/style.css',
array($parent_style),
wp_get_theme()->get('Version')
);
}
add_action('wp_enqueue_scripts', 'my_theme_enqueue_styles');
,这里是样式表是如何被装在我的网站 似乎加载为“Bigpoint的默认-CSS”然后再次添加“child-style-css”
****更新:我发现我的css被加载两次,在我的父主题的functions.php文件中被调用的答案为:
wp_register_style('bigpoint-default', get_stylesheet_uri(), '1.0');
所以我用了thi s到撤消:
function unhook_parent_style() {
wp_dequeue_style('bigpoint-default');
wp_deregister_style('bigpoint-default');
}
add_action('wp_enqueue_scripts', 'unhook_parent_style', 20);
谢谢Andrew帮我在woocommerce css之后加载我的样式表。我发现这在父主题functions.php文件,我相信这是我的CSS文件的其他加载发生的地方:wp_register_style('bigpoint-default',get_stylesheet_uri(),'1.0');但我不知道如何在我自己的functions.php文件中处理这个问题。 –
如果我看不到所有的代码,我都无法回答这个问题。 –
我想通了,并张贴在我的问题,感谢帮助一个WordPress新手:) –