Archived topic
Add class to body when merge header is active
5 replies · Started by Markus on October 27, 2022
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?
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
Ahh, I see! That works for me, I can use that class to add adjustments. Providing a link in the private information for reference.
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.
Hi, thanks for your reply and fast support. I got it working with the .header-wrap class!
Glad to hear that!