• Resolved sgumby

    (@sgumby)


    How can I get all Elementor styles to load before the theme or child theme styles?? If this doesn’t happen the only way I can override the default Elementor? Styles is to use !important? which makes really messy CSS.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support enmanueldiaz

    (@enmanueldiaz)

    Hello,

    Thank you for reaching out with your query regarding Elementor style load order. I understand your concern about maintaining clean CSS and avoiding the use of “!important” whenever possible.

    Generally, the styles in WordPress are loaded in the order they are enqueued. The challenge here is that Elementor’s styles are typically loaded after the theme’s styles, which is why you might be finding it necessary to use “!important” to override them.

    One potential solution to this issue could be to manually adjust the order in which the stylesheets are loaded. You can do this by deregistering the stylesheets and then enqueuing them back in the order you need. This would involve using WordPress’s wp_enqueue_scripts action and the wp_dequeue_style and wp_enqueue_style functions.

    However, please note that this kind of customization involves writing custom code and modifying core theme and plugin files, which can have unintended side effects if not done correctly. It also requires a good understanding of WordPress and PHP.

    Here’s a basic idea of how it might be done:

    function adjust_styles_load_order() {
       wp_dequeue_style('elementor-frontend');
       wp_enqueue_style('elementor-frontend');
    }
    add_action('wp_enqueue_scripts', 'adjust_styles_load_order', 999);
    

    In this example, ‘elementor-frontend’ is the handle for Elementor’s frontend styles, and the number 999 is the priority – the higher the number, the later the function is run. You would need to replace ‘elementor-frontend’ with the correct handle for your specific situation.

    Please be aware that this is a very simplified example and may not work for your specific situation. Also, these modifications should be made in a child theme to prevent them from being overwritten when the theme or plugin is updated.

    Although I’d love to assist you with this directly, providing custom code solutions falls outside of the scope of support we can provide at Elementor. We highly recommend collaborating with a knowledgeable developer if you’re not comfortable with coding.

    Thank you!

    Thread Starter sgumby

    (@sgumby)

    This really needs to be a feature that you add into Elementor. This is a constant struggle every single time I use your plug-in…. and I’m sure I’m not the only one with this problem.

    You are supposed to be a plug-in to ASSIST the theme so if your styles override the theme and give us no way to get around it other than to use fancy creative coding….That means you’re plugin is not very good. And I’ve done this enough to know that you can set the priority of your styles so that they load before the theme. 

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Force All Elementor Styles to Load before theme styles.’ is closed to new replies.