Very nice plugin
-
If you love this plugin like me but want to avoid having the cookie titles show up as
<h2>headings on every page (which can clutter your HTML heading structure and potentially impact SEO), you can use this small JavaScript tweak.It will replace only the two headings “Consenso sui cookie” / “Cookie consent” and “Preferenze sui cookie” / “Cookie preferences” with
<span>elements — visually identical and still accessible to screen readers, but without affecting your page’s heading hierarchy.document.addEventListener('DOMContentLoaded', () => { document.querySelectorAll('.pressidium-cc-theme h2') .forEach(h => { const txt = h.textContent.trim(); if ( txt === 'Consenso sui cookie' || txt === 'Preferenze sui cookie' || txt === 'Cookie consent' || txt === 'Cookie preferences' ) { const s = document.createElement('span'); s.className = h.className; s.innerHTML = h.innerHTML; s.setAttribute('role', 'heading'); s.setAttribute('aria-level', '6'); h.replaceWith(s); } }); });Where to put it:
Add it to your theme’s footer (just before</body>) or via a custom snippets plugin.Result:
- Keeps the cookie banner fully functional
- Maintains accessibility with
role="heading"andaria-level="6" - Removes unnecessary
<h2>tags from your content structure on every page
This way you can keep using the plugin exactly as it is, while keeping your heading structure clean for SEO.
You must be logged in to reply to this review.