0
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?

1
  • There are definitely some work around for that (Not in WordPress way), but that's not worth having a single css file.
    – Abhik
    May 18, 2022 at 17:39

1 Answer 1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.