admin管理员组文章数量:1385016
New to WordPress. I have been working on my own child theme. Everything is working so far but I have a question on dequeuing a parent theme's CSS.
Right now, the parent theme enqueues a AOS.css
file which adds "action of scroll". I am not a big fan of this effect and want to dequeue this style entirely in my child theme. My question is if I dequeue but the parent theme still includes AOS related stuff would that crash the site or I can safely remove AOS.css
?
New to WordPress. I have been working on my own child theme. Everything is working so far but I have a question on dequeuing a parent theme's CSS.
Right now, the parent theme enqueues a AOS.css
file which adds "action of scroll". I am not a big fan of this effect and want to dequeue this style entirely in my child theme. My question is if I dequeue but the parent theme still includes AOS related stuff would that crash the site or I can safely remove AOS.css
?
- 1 You should be good to dequeue it, but you may then need to address certain styling deficiencies by writing them into your child style.css. – Tony Djukic Commented May 3, 2020 at 22:21
2 Answers
Reset to default 0Tony has it right, you can dequeue the style without the site having an error. That is because of the way CSS works. If the DOM can't find a specific CSS class/ID that is in the HTML it is simply ignored. Tony is also right, that you may need to add some styles back in if they were included in the, now removed, CSS file.
If you were removing a JavaScript file on the other hand you would need to be more careful to make sure that one of the removed functions wasn't going to cause a conflict elsewhere. A quality theme developer will take that into consideration and often wrap functions to make sure all functions are there, but that's not always the case.
Try this code in the currently existing theme for the dequeue style.
add_action( 'wp_enqueue_scripts', 'mywptheme_child_deregister_styles', 11 );
function mywptheme_child_deregister_styles() {
wp_dequeue_style( 'mywptheme' );
}
本文标签: Dequeue CSS of the Parent Theme
版权声明:本文标题:Dequeue CSS of the Parent Theme 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744498873a2609197.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论