Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

enqueueing child theme CSS AFTER WooCommerce CSS

  • HHi, I’m trying to style some specific things on my WooCommerce pages (like buttons, error message boxes etc.) But my CSS – which is in my Child theme – is getting overwritten all the time. Would it be a good idea to get my GeneratePress Child Theme CSS to load after the WooCommerce CSS? And if so, please could you help me with the code to enqueue this.
    Currently I have the following code in my Child Theme PHP file:

    <?php
    add_action('enqueue_block_editor_assets', function() {
        // Enqueue the child theme's style.css for the block editor
        wp_enqueue_style(
            'child-theme-editor-style', // Unique handle for the stylesheet
            get_stylesheet_uri(),      // Gets the full URL to the child theme's style.css
            array(),                   // Dependencies (e.g., ['wp-edit-blocks'] if needed)
            wp_get_theme()->get('Version') // Version number from the theme
        );
    });
    
    /*Opens site wrapper div */
    add_action('generate_before_header', 'tct_open_wrapper');
    function tct_open_wrapper(){
        echo '<div class="site-wrapper">';
    }
    
    /*Closes site wrapper div */
    add_action('generate_after_footer', 'tct_close_wrapper');
    function tct_close_wrapper(){
        echo '</div>';
    }
    
    Thank you!
    
    ?>
  • Hi there,

    There isn’t a way to change the order of the CSS files, unfortunately!

    In this case, you need to use more specific selectors so your CSS can override Woocommerce’s CSS.

  • Okay thank you Yin,
    I understand.

  • You are welcome   🙂

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