Cannot print out theme child-style CSS version on browser
-
Hello, word! I need some help / orientation to properly versioning CSS file for theme child styles. I have searched a lot about it and found pretty much same solution but I cannot make it work. This is the code I’m using in theme child’s functions.php:
function my_theme_enqueue_styles() {
$parent_style = 'parent-style';
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array( $parent_style ),
'[css_version_number]'
);
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );And these are the CSS lines printed out by broswer – “4.24.2” is the version of “parent” theme CSS file:
<link rel='stylesheet' id='child-style-css' href='https://[domain]/wp-content/themes/Divi-child/style.css?ver=4.24.2' type='text/css' media='all' />
<link rel='stylesheet' id='divi-style-css' href='https://[domain]/wp-content/themes/Divi-child/style.css?ver=4.24.2' type='text/css' media='all' />In my opinion, WP is not doing what theme child’s functions.php is supposed to do – not even printing out the CSS lines in correct / proper order.
I’m using Divi theme as “parent” and Total Cache plugin for caching. I already tried by changing version number in header for “child” CSS file without success – wp_get_theme()->get(‘Version’) does get the version number properly from header of CSS file but ‘add_action( ‘wp_enqueue_scripts’, ‘my_theme_enqueue_styles’ );’ doesn’t seem to print out correct child CSS file.
It is important to mention that both “wp_enqueue_style()” functions result in NULL despite “get_template_directory_uri()” and “get_stylesheet_directory_uri()” shows valid data.
I would appreciate some bright light on this issue. Thank you so very much in advance.
The topic ‘Cannot print out theme child-style CSS version on browser’ is closed to new replies.