After reading several posts here (including [1] and [2]) and testing with Wordpress 4.5.3 using Twenty Sixteen as parent theme, I think the following (in functions.php) code must be correct:

function childtheme_enqueue_styles() {
    $parent_style = 'twentysixteen-style';
    wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'childtheme-style', get_stylesheet_directory_uri() . '/style.css', array( $parent_style ), wp_get_theme()->get('Version'));

add_action( 'wp_enqueue_scripts', 'childtheme_enqueue_styles' );

It loads the parent stylesheet (with parent theme version number) and then the child theme stylesheet (with child theme version number). This seems to enable independent cache busting.

I also read the documentation and was so confident that I updated it to reflect my findings ...

PS! My reputation is too low to comment or to post a new answer to one of the existing posts, so that is why I'm "forced" to post this as a new question. Anyway, I think the question is OK - and the docs get reviewed if I'm wrong.

  • I prefer more dynamic way of output version (for eg: using filetime() of the child theme css ) – bravokeyl Aug 8 '16 at 13:36
  • @hansfn filetime goes to the file system on each request. Not really the best thing to do from a performance perspective – kraftner Aug 8 '16 at 15:08
  • 1
    @kraftner Using filemtime (not filetime) is of course not an option unless while you are developing a theme. – hansfn Aug 8 '16 at 16:43
  • Isn't the above code working as expected? Is the ressource loaded from cache even with an incremented child theme version? – Hans Spieß Mar 10 '17 at 8:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.