[Resolved] Add class to body when merge header is active

Home Forums Support [Resolved] Add class to body when merge header is active

Home Forums Support Add class to body when merge header is active

  • This topic has 5 replies, 3 voices, and was last updated 5 months ago by David.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2389220
    Markus

    Hello, I need to make adjustments (set color on svg logo etc.) to the header depending on if a merge header element is used on the page. I was thinking of adding a class to the body and added a script snippet directly in the page hero content like so:

    
    <script>
    	document.body.classList.add('merge-header');
    </script>
    

    It works but this creates the page-hero section in the top of the page which seems a bit unnecessary when Gutenberg is being used. Is there another way to detect if the header merge element is used and then filter the body class?

    #2389244
    Fernando
    Customer Support

    Hi Markus,

    Where’s the SVG located? If it’s in the Header, by default, the header is wrapped in a div with class – header-wrap if merged.

    Can you provide the link to the site in question for reference?

    You may use the Private Information field for this: https://docs.generatepress.com/article/using-the-premium-support-forum/#private-information

    #2389273
    Markus

    Ahh, I see! That works for me, I can use that class to add adjustments. Providing a link in the private information for reference.

    #2389569
    David
    Staff
    Customer Support

    Hi there,

    did you get this working ? As the topic has been marked as resolved ( Which auto deletes any Private Info ).
    If you still need assistance , please add the URL back in the private info.

    #2389572
    Markus

    Hi, thanks for your reply and fast support. I got it working with the .header-wrap class!

    #2389640
    David
    Staff
    Customer Support
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.