document.addEventListener('DOMContentLoaded', function() { var page = document.querySelector('.page-id-1549'); if (!page) return; var btns = document.querySelectorAll('.elementor-widget-button a[href="#"]'); var sections = document.querySelectorAll('.elementor-inner-section'); if (btns.length < 3) return; var catMap = { 'all': 'all' }; btns.forEach(function(b) { var t = b.innerText.toUpperCase().trim().replace(/\s+/g, '_'); if (t === 'ALL') catMap['all'] = 'all'; else catMap[t.toLowerCase()] = t.toLowerCase(); }); var sectionCat = {}; sections.forEach(function(s) { var h = s.querySelector('h5'); if (!h) return; var txt = h.innerText.toUpperCase().trim().replace(/\s+/g, '_'); if (~txt.indexOf('BEGINNER')) sectionCat['beginner\'s_guide'] = s; else if (~txt.indexOf('DEEPER')) sectionCat['deeper_practices'] = s; else if (~txt.indexOf('PRODUCT')) sectionCat['product_stories'] = s; else if (~txt.indexOf('LIFESTYLE')) sectionCat['lifestyle'] = s; }); function doFilter(cat) { btns.forEach(function(b) { b.style.background = ''; b.style.color = ''; }); Object.keys(sectionCat).forEach(function(k) { sectionCat[k].style.display = (cat === 'all' || k === cat) ? '' : 'none'; }); btns.forEach(function(b) { var t = b.innerText.toUpperCase().trim().replace(/\s+/g, '_'); if (t.startsWith(cat.toUpperCase()) || (cat === 'all' && t === 'ALL')) { b.style.background = '#d4a0b0'; b.style.color = '#fff'; } }); } btns.forEach(function(b) { b.addEventListener('click', function(e) { e.preventDefault(); var t = this.innerText.toUpperCase().trim().replace(/\s+/g, '_'); doFilter(t.toLowerCase()); }); }); doFilter('all'); });