Bootstrap CSS Loads After Parent and Child Theme CSS - Acme Themes

Best Premium and Free WordPress Themes Forums Event Star Bootstrap CSS Loads After Parent and Child Theme CSS

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #81701
    Daniel Bye
    Participant

    Hi,

    Like title says, bootstrap CSS is loading after the parent and child theme CSS files.

    I’m using the recommended function from WordPress.org to load the child theme:

    add_action( 'wp_enqueue_scripts', 'event_star_child_enqueue_styles' );
    function event_star_child_enqueue_styles() {
     
        $parent_style = 'event-star-style';
     
        wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
        wp_enqueue_style( 'child-style',
            get_stylesheet_directory_uri() . '/style.css',
            array( $parent_style ),
            wp_get_theme()->get('Version')
        );
    }

    Do you have a solution please which adds bootstrap style, then the parent style, then finally the child theme style?

    Many thanks.

    #81824
    Daniel Bye
    Participant

    Hi,

    There’s been no reply from premium support in 2 days. In the end I sorted this problem myself through research – by making bootstrap dependent on the parent theme:

    add_action( 'wp_enqueue_scripts', 'bigint_enqueue_styles' );
    function bigint_enqueue_styles() {
        $parenthandle = 'event-star-style';
        $theme = wp_get_theme();
        wp_enqueue_style( $parenthandle, get_template_directory_uri() . '/style.css', 
            array('bootstrap'),
            $theme->parent()->get('Version')
        );
        wp_enqueue_style( 'child-style', get_stylesheet_uri(),
            array( $parenthandle ),
            $theme->get('Version')
        );
    }

    I noticed the free theme loads bootstrap CSS after the theme CSS too as soon as a child theme is added. Just one of the issues this causes is that Bootstrap creates a coloured menu item background on hover.

    Anyway, the solution above works. This topic can be closed.

    #81953
    acmethemes
    Keymaster

    Dear Daniel,
    That’s good to know the problem has been solved.
    Best Regards!

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