I got problems with my twentytwenty child theme and hope, that someone can help me.
In order to optimize my website for speed, I'd like to use critical css as inline code. To do that, I wanted to call style.css asynchronously, what means I have to set it in header.php manually, without using wp_enqueue_style.
When I created the child theme in the past, I unfortunately copied the whole parent theme and made several modifications. That's the reason, why I'm disabling the parent theme complete, to avoid double loading of these big style files.
With the following code in functions.php I disabled the parent theme and enqueued the child theme:
function child_theme_styles()
{
wp_dequeue_style( 'twenty-twenty-style' );
wp_deregister_style( 'twenty-twenty-style' );
wp_enqueue_style('twentytwenty-child-style', get_stylesheet_directory_uri() . '/style.css', array('twentytwenty-style'));
}
add_action('wp_enqueue_scripts', 'child_theme_styles');
Strangely, the following line is still being loaded in head (which is not the real problem though):
<link rel="stylesheet" id="twentytwenty-print-style-css" href="https://www.mydomain.de/wp-content/themes/twentytwenty/print.css?ver=6e696dca833adce1dfc8a4b185ba1bf1" media="print">
The actual problem is, that I'm not able to disable enqueuing the child theme style.css, to place the code manually in header.php. When I comment out or delete the last line in the mentioned function, the style.css of my child theme is still loaded (see screenshot below)!
wp_enqueue_style('twentytwenty-child-style', get_stylesheet_directory_uri() . '/style.css', array('twentytwenty-style'));
There is no other custom code, that is loading this line. So, how can this happen? What is the right way to stop my child styles from loading automatically?