Update version number of child style.css

Hi there,

I want to be able to update the version number of the child-theme style.css manually. I need to to this to prevent caching problems.
So far I found this post, but it is from 2016, so I would like to know if there is a better solution for this now.

thanks a lot

Hi @Buschmann,

I’ve just tested with the following code and it’s still working fine:

function wuwo_theme_styles() {
  // de-register the child theme stylesheet registered by X theme:
  wp_dequeue_style( 'x-child' );
  wp_deregister_style( 'x-child' );

  $theme_version = wp_get_theme()->get('Version');

  // Register and Enqueue our style.css with our own handle and version:
  wp_register_style( 'wuwo-styles', get_stylesheet_directory_uri() . '/style.css', array( 'x-stack' ), $theme_version, 'all' );
  wp_enqueue_style( 'wuwo-styles' );
}
// Enqueue this theme's scripts and styles (after parent theme)
add_action('wp_enqueue_scripts', 'wuwo_theme_styles', 99);

Cheers!

Ok, thanks. I was just wondering, is it not slowing down the webpage with deregistering and re-registering this script?
thanks again

Hi Sören,

No, it shouldn’t. Have a great day! :slight_smile:

ok, it works for me . thanks a lot!

You’re always welcome!

Cheers.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.