Archived topic
Set child theme style.css to last css file loaded?
2 replies · Started by Sneaky on May 24, 2022
Viewing posts 1–3 of 3
Can you provide me with the correct code to set the child theme style.css file to load last with GeneratePress?
I know it is related to wp_enqueue_style, e.g. in another site I use with the Astra theme, it has this in the functions.php file. What do I edit so I can get it to work with GeneratePress?
/** Define Constants **/
define( 'CHILD_THEME_MYTHEME_VERSION', '1.0.0' );
/** Enqueue styles **/
function child_enqueue_styles() {
wp_enqueue_style( 'mytheme-theme', get_stylesheet_directory_uri() . '/style.css', array('astra-theme-css'), CHILD_THEME_MYTHEME_VERSION, 'all' );
}
add_action( 'wp_enqueue_scripts', 'child_enqueue_styles', 999 );
Thanks
Hi there,
try this snippet:
add_action( 'wp_enqueue_scripts', function() {
wp_dequeue_style( 'generate-child' );
wp_enqueue_style( 'generatepress-child', get_stylesheet_uri(), array(), filemtime( get_stylesheet_directory() . '/style.css' ), 'all' );
}, 999 );
Hey David - That's cool! Thanks. I'll try that out.
Best!
This archived topic is closed to new replies.