I was using a child theme and following WordPress’s recommended way to load a parent’s stylesheet with wp_enqueue_style in the child theme functions.php file. However, the child theme stylesheet was loading before the parent theme stylesheet.
This was caused by a hard-coded reference to the stylesheet in the parent theme header.php file. I removed the hard-coded reference in the child theme header.php file and made the following modifications to my child theme wp_enqueue_style declarations:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action( 'wp_enqueue_scripts', 'my_enqueue_assets' ); | |
| function my_enqueue_assets() { | |
| wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' ); | |
| wp_register_style( 'child-style', get_stylesheet_directory_uri().'/style.css', array( 'parent-style' ) ); | |
| wp_enqueue_style( 'child-style' ); | |
| } |