We're merging with GenerateBlocks! Learn more here.

[Resolved] How to move inline style to head

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support How to move inline style to head

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #19771
    Ben
    Participant

    Using wp show posts with generatepress.
    WPSP seems to insert inline style at the point I insert the shotcode.
    eg.
    <div class=”gb-container gb-container-3cab30f1″><div class=”gb-inside-container”>
    <style>.slick-slider#wpsp-312 {margin-left: 0px; }.slick-slider#wpsp-312 .wp-show-posts-inner {margin-left: 1em; ….

    and
    <style>.wp-show-posts-columns#wpsp-312 {margin-left: -2em; }.wp-show-posts-columns#wpsp-312 .wp-show-posts-inner {margin: 0 0 2em 2em; }</style>

    Is there a way to move this to the head of document so that I can keep the HTML to be valid?

    Error I’m getting is

    “Element style not allowed as child of element div in this context.”

    Many thanks

    #19790
    Tom
    Keymaster

    Hi there,

    This is a limitation to shortcodes, unfortunately. By the time the shortcode is rendered by WordPress, the <head> of your website has already been rendered and can’t be manipulated.

    We could move those styles to the footer, but then you’ll see a flash of unstyled content until the CSS is reached.

    Once we transition to a block-based system instead of shortcode-based, this will no longer be an issue 🙂

    #19885
    J
    Participant

    Hi there,

    Running into the same html validation error trying to get website that uses WPSP WCAG 2.1 compliant.

    Question 1: How can we move the styles to the footer?

    Question 2: When will the transition to a block-based system be finished?

    WPSP is one of our favorite plugins!

    J

    #19936
    Tom
    Keymaster

    Have you tried a plugin like Autoptimize? I believe it has the capability to grab scripts and styles from the body and move them into the head or footer. Might be worth trying.

    No timetable on a block yet, but it’s something we’re very keen on building soon.

    #21004
    J
    Participant

    I now use Automptimize. Works! No longer html validation errors.

    Thanks for the tip.

    #21112
    Tom
    Keymaster

    No problem 🙂

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