Enqueue child theme styles with versioning..
-
Hi. Trying to unravel dated information on this topic. As I understand it, as of 2017 you no longer need to enqueue the child theme stylesheet as WordPress automatically does it for you. Correct?
What I want to do is add a version number to the child styles for helping with cache busting. I looked here: https://developer.ww.wp.xz.cn/themes/advanced-topics/child-themes/
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' ); function my_theme_enqueue_styles() { wp_enqueue_style( 'child-style', get_stylesheet_uri(), array( 'parenthandle' ), wp_get_theme()->get('Version') // this only works if you have Version in the style header ); }This added a versioned copy of my child stylesheet, but it was a duplicate! Would the proper thing to do is somehow dequeue the other child stylesheet?
As far as the parent styles my current theme declares them like the below if that makes a difference.
function child_enqueue_parent_theme_style() { wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); } add_action('wp_enqueue_scripts', 'child_enqueue_parent_theme_style');
The topic ‘Enqueue child theme styles with versioning..’ is closed to new replies.