[Support request] Set child theme style.css to last css file loaded?

Home Forums Support [Support request] Set child theme style.css to last css file loaded?

Home Forums Support Set child theme style.css to last css file loaded?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #2230420
    Sneaky

    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

    #2230450
    David
    Staff
    Customer Support

    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 );
    #2574392
    Chris

    Hey David – That’s cool! Thanks. I’ll try that out.

    Best!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.