Site icon Hip-Hop Website Design and Development

Recommended way to load / enqueue parent and child stylesheet to enable cache busting

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.