
This snippet hides the Loop Widget by checking for .e-loop-item and hiding the widget when no items are present. This prevents empty loop sections from occupying space on the page.
Copy & paste the scripts before the </body> tag of your project. If you added them before for another setup, skip this step.
Place the code in an HTML widget or add it through Elementor → Custom Code (before the closing </body> tag) either globally or only on selected pages.
Paste the code through the page or site settings, or add it via Elementor → Custom Code (before </body>) for broader use.
body:not(.elementor-editor-active)
[ou-hide-if-empty-loop]:not(:has(.e-loop-item)) {
display: none !important;
}Paste the script through Elementor → Custom Code (set to load after </body>) for site-wide or page-specific loading.
Place the PHP snippet in your theme’s functions.php file or add it using a code snippets plugin to enable the logic.
Add the attribute ou-hide-if-empty-loop to the parent wrapper that contains the Loop Grid. When the loop renders zero items, the entire wrapper section will be hidden on the live site.
Some solutions only work on the live site. Always publish and test after each change, as results may not appear in the editor.