add_action('wp_footer', function () { $script = <<<'JS' (function () { if ( window.location.pathname.replace(/\/$/, '') !== '/product-directory' ) { return; } function cleanCatalogue() { const products = document.querySelectorAll( 'ul.products li.product' ); if (!products.length) { return; } document.querySelectorAll( '.post_content > .page_info' ).forEach(function (section) { const heading = section.querySelector( '.page_subtitle' ); if ( heading && heading.textContent.includes('did not match') ) { const parent = section.parentElement; section.style.setProperty( 'display', 'none', 'important' ); if ( parent && parent.children.length === 1 ) { parent.style.setProperty( 'display', 'none', 'important' ); } } }); } if (document.readyState === 'loading') { document.addEventListener( 'DOMContentLoaded', cleanCatalogue ); } else { cleanCatalogue(); } })(); JS; echo ''; }, 99);