I accidentally discovered that my child theme CSS is get called twice. I found that this is an old issue (see here and here), but I don't know how to solve it in my situation.
<link rel='stylesheet' id='parent-style-css' href='http://infopsi.md/wp-content/themes/twentyseventeen/style.css?ver=4.8.1' type='text/css' media='all' />
<link rel='stylesheet' id='child-style-css' href='http://infopsi.md/wp-content/themes/twentyseventeen-child/style.css?ver=0.1' type='text/css' media='all' />
<link rel='stylesheet' id='twentyseventeen-style-css' href='http://infopsi.md/wp-content/themes/twentyseventeen-child/style.css?ver=4.8.1' type='text/css' media='all' />
This is the function that I use to enqueue the parent and child theme stylesheets:
/** Enqueue the parent and child theme stylesheets **/
if ( !function_exists( 'my_theme_enqueue_styles' ) ):
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 ),
wp_get_theme()->get('Version')
);
}
endif;
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
I tried to add the wp_dequeue_style( 'twentyseventeen-style' );
to the function, but this doesn't solved the issue. Any suggestions?
style.css
can be called by the parent theme (in parentfunctions.php
) then just remove the call in the childfunctions.php
wp_enqueue_style( 'child-style', ...
is not needed? I removed that part from my function and it works! Thank you!