Title: Hide if empty
Last modified: June 13, 2022

---

# Hide if empty

 *  Resolved [claudiaiw](https://wordpress.org/support/users/claudiaiw/)
 * (@claudiaiw)
 * [3 years, 12 months ago](https://wordpress.org/support/topic/hide-if-empty-2/)
 * Hi,
 * is there a way to hide the block if it’s empty, instead of only showing “none
   found”?
 * Regards
    Claudia

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Brecht](https://wordpress.org/support/users/brechtvds/)
 * (@brechtvds)
 * [3 years, 12 months ago](https://wordpress.org/support/topic/hide-if-empty-2/#post-15732027)
 * Hi Claudia,
 * If you make the “None found” text empty, nothing should show up if nothing is
   found. You can change that text in the sidebar when editing the block.
 *  Thread Starter [claudiaiw](https://wordpress.org/support/users/claudiaiw/)
 * (@claudiaiw)
 * [3 years, 12 months ago](https://wordpress.org/support/topic/hide-if-empty-2/#post-15732415)
 * Great that works.
 * I implemented the shortcode by PHP (because the widgets were not working) and
   wrapped a div around it for styling reasons (as there is none from the plugin..)
 *     ```
       function iw_related_posts() {
           echo '<div class="related-posts">' . do_shortcode( '[custom-related-posts title="Beiträge aus dem Projekt" none_text=""]' ) . '</div>'; 
       }
       add_action('generate_before_right_sidebar_content','iw_related_posts', 10);
       ```
   
 * It would be perfect to set this into an if query, so that the div-wrap also doesn’t
   show up.
 * Any hint for that?
 *  Thread Starter [claudiaiw](https://wordpress.org/support/users/claudiaiw/)
 * (@claudiaiw)
 * [3 years, 12 months ago](https://wordpress.org/support/topic/hide-if-empty-2/#post-15732462)
 * As a workaround, I remove the element by jquery if it’s empty.
 *  Plugin Author [Brecht](https://wordpress.org/support/users/brechtvds/)
 * (@brechtvds)
 * [3 years, 12 months ago](https://wordpress.org/support/topic/hide-if-empty-2/#post-15733013)
 * You could put the output of the `do_shortcode` function in a variable first and
   check if that’s empty before outputting the surrounding div.
 *  Thread Starter [claudiaiw](https://wordpress.org/support/users/claudiaiw/)
 * (@claudiaiw)
 * [3 years, 12 months ago](https://wordpress.org/support/topic/hide-if-empty-2/#post-15733413)
 * Sure 😀
    that’s the better solution, thanks for the tip

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Hide if empty’ is closed to new replies.

 * ![](https://ps.w.org/custom-related-posts/assets/icon-256x256.png?rev=2007814)
 * [Custom Related Posts](https://wordpress.org/plugins/custom-related-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/custom-related-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/custom-related-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-related-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-related-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-related-posts/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [claudiaiw](https://wordpress.org/support/users/claudiaiw/)
 * Last activity: [3 years, 12 months ago](https://wordpress.org/support/topic/hide-if-empty-2/#post-15733413)
 * Status: resolved