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
Add a comment  | 

1 Answer 1

Reset to default 2

No, 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