Skip to content

Snippet: Prevent the Child Theme’s Style.css File from Loading

Simple go to your child theme's functions.php file and replace the function that enqueues the parent CSS file with the following code. This will re-register the child theme's style.css and re-register the parent theme's style.css with the correct handle.

 * Load the parent style.css file
 * @link
function total_child_enqueue_parent_theme_style() {

	// First de-register the main stylesheet (which is now your child theme style.css)
	wp_dequeue_style( WPEX_THEME_STYLE_HANDLE );
	wp_deregister_style( WPEX_THEME_STYLE_HANDLE );

	// Add the parent style.css with the main style handle
	wp_enqueue_style( WPEX_THEME_STYLE_HANDLE, get_template_directory_uri().'/style.css', array(), WPEX_THEME_VERSION );

add_action( 'wp_enqueue_scripts', 'total_child_enqueue_parent_theme_style' );
All PHP snippets should be added via child theme's functions.php file or via a plugin. We recommend Code Snippets (100% Free) or WPCode (sponsored)
Back To Top