Search code examples
wordpresswordpress-hook

Manipulate theme version - hook into wp_get_theme()


I want to alter the version of a theme, returned by wp_get_theme(). I checked in the source code, and saw that wp_get_theme() returns new WP_Theme( $stylesheet, $theme_root ); and there is no hook involved in the process...

I then went one step deeper and checked in class WP_Theme to maybe find a hook, but from what I've seen there is no useful hook in there either.

So can you give me any insight on how to manipulate the theme version returned by wp_get_theme() please?


Solution

  • it's not possible to change the theme version, without actually updating the themes style.css file.

    You have a few options now:

    1. Use something elese than the theme version
    2. update the themes style.css file
    3. add to the theme version, for example a date (but that won't be refleced when someone gets the theme version somewhere else

    What is your goal? For keeping the most recent files from a build proccess out of the cache, I personally recommend using a HASH in the filename, over the theme version. This is how it is done in sage10 and bud.js.