• Resolved carlfmichel

    (@carlfmichel)


    First of all, wonderful plugin! Thank you for making it available. I’m using the flexible content with dynamic rendering. I have set all the layouts to pull their css styling from the main css file of the site. However I’m noticing that when I have multiple layouts on a page that the main style sheet is being add multiple times on the front-end. Do you have any recommendations on how I might be able to have the layouts pull from the main stylesheet of the site but not have it include the same stylesheet for each layout and also still perform the dynamic render? The reason why I am using the same style sheet is because I have baked in a bunch of global styling that the layouts and many other elements on the site pull from.

    Thank you in advance for your insights!

Viewing 1 replies (of 1 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Thanks for the feedback and sorry for the late answer. The reason why the layouts CSS styles are enqueued multiple times is because you use the same CSS file in all layouts settings, and those files are rendered using a dynamic enqueue name based on the layout name (thus the duplication).

    If you want to use a global CSS file (and not splitted CSS enqueue files), then you should leave the CSS render files settings empty, and use the following code to enqueue a global CSS file when the Flexible Content is rendered:

    add_action('acfe/flexible/enqueue/name=my_flexible', 'my_acf_flexible_enqueue', 10, 2);
    function my_acf_flexible_enqueue($field, $is_preview){
    
        wp_enqueue_style('my-style', 'https://www.example.com/style.css');
    
    }
    

    You’ll find more code example in the FAQ here.

    Hope it helps!

    Regards.

Viewing 1 replies (of 1 total)

The topic ‘Single Shared Stylesheet’ is closed to new replies.