admin管理员组文章数量:1199802
function loadOneStylePage(){
wp_enqueue_style( 'main-style', get_template_directory_uri() . '/styles/main.css', array(), _S_VERSION );
wp_enqueue_style( 'main-style-separate-file', get_template_directory_uri() . '/styles/main.css', array(), _S_VERSION );
//i would like to merge the two files?
wp_add_inline_style( 'main-style-separate-file', 'main-style' );
}
add_action('wp-enquueue_scripts', 'loadOneStylePage');
Ideally, I would like to put these two together as 1 file. I know i can merely edit the single file and plainly add all the css together but for the sake of creating a custom theme and providing additional options is never bad.
I know the wp_add_inline_style api merges inline styling but is there a way to merge actual files?
function loadOneStylePage(){
wp_enqueue_style( 'main-style', get_template_directory_uri() . '/styles/main.css', array(), _S_VERSION );
wp_enqueue_style( 'main-style-separate-file', get_template_directory_uri() . '/styles/main.css', array(), _S_VERSION );
//i would like to merge the two files?
wp_add_inline_style( 'main-style-separate-file', 'main-style' );
}
add_action('wp-enquueue_scripts', 'loadOneStylePage');
Ideally, I would like to put these two together as 1 file. I know i can merely edit the single file and plainly add all the css together but for the sake of creating a custom theme and providing additional options is never bad.
I know the wp_add_inline_style api merges inline styling but is there a way to merge actual files?
Share Improve this question asked May 18, 2022 at 16:49 ArtArt 1 1- There are definitely some work around for that (Not in WordPress way), but that's not worth having a single css file. – Abhik Commented May 18, 2022 at 17:39
1 Answer
Reset to default 2No, there’s no function to merge files like that. If you want a single CSS file you need to make a single CSS file.
本文标签: wp enqueue styleAdd wpaddinlinestyle into another wpaddinlinestyle for better performance
版权声明:本文标题:wp enqueue style - Add wp_add_inline_style into another wp_add_inline_style for better performance 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738582390a2101240.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论