Snippets: Load Child Theme style.css After Parent Theme style.css

By default when you use a child theme in WordPress it doesn't actually load he parent CSS file so you generally would add a function to your child theme's functions.php to load the parent CSS file. Now, this results in the parent CSS file loading after the child theme style.css so the parent theme's CSS will take priority. If you want your child theme's style.css file to load after the parent style.css so that your child theme takes priority you can use the following function to enqueue the parent CSS file instead of the default way of loading it.

function my_load_child_theme_styles() {

	if ( ! defined( 'WPEX_THEME_STYLE_HANDLE' ) ) {
		wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css', array(), '1.0' );

	// 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 );

	// Re-add child CSS with parent as dependency
	wp_enqueue_style( 'child-css', get_stylesheet_directory_uri() . '/style.css', array( WPEX_THEME_STYLE_HANDLE ), '1.0' );

add_action( 'wp_enqueue_scripts', 'my_load_child_theme_styles' );
All PHP snippets should be added via a child theme's functions.php file.