Title: Hide empty categories in shortcode
Last modified: June 22, 2025

---

# Hide empty categories in shortcode

 *  Resolved [teeboy4real](https://wordpress.org/support/users/teeboy4real/)
 * (@teeboy4real)
 * [10 months, 2 weeks ago](https://wordpress.org/support/topic/hide-empty-categories-in-shortcode/)
 * Hi
 * please can you add feature or new parameter to hide categories with empty ads
   or zero ads in [adverts_categories] shortcode, I created lots of categories but
   I dont want users viewing empty categories without ads, only the categories containing
   ads should be visible.
 * Thanks

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

 *  Plugin Author [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * (@gwin)
 * [10 months, 2 weeks ago](https://wordpress.org/support/topic/hide-empty-categories-in-shortcode/#post-18524069)
 * Hi,
 * you can hide the empty categories by adding the below code snippet in your theme
   functions.php file (or even better by creating a new blank plugin and pasting
   the code there [https://wpadverts.com/blog/how-to-use-code-snippets-in-wordpress/](https://wpadverts.com/blog/how-to-use-code-snippets-in-wordpress/))
 *     ```wp-block-code
       add_filter( "adverts_categories_query", function( $args ) {  $args["hide_empty"] = 1;  return $args;} );
       ```
   
 *  Thread Starter [teeboy4real](https://wordpress.org/support/users/teeboy4real/)
 * (@teeboy4real)
 * [10 months, 2 weeks ago](https://wordpress.org/support/topic/hide-empty-categories-in-shortcode/#post-18525151)
 * Thanks a lot the code worked, but does not work for sub categories when using**(
   show=all)** parameters
 *  Plugin Author [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * (@gwin)
 * [10 months, 1 week ago](https://wordpress.org/support/topic/hide-empty-categories-in-shortcode/#post-18525756)
 * For sub-categories you will need another code snippet
 *     ```wp-block-code
       add_filter( "adverts_categories_query_sub", function( $args ) {  $args["hide_empty"] = 1;  return $args;} );
       ```
   
 *  Thread Starter [teeboy4real](https://wordpress.org/support/users/teeboy4real/)
 * (@teeboy4real)
 * [10 months, 1 week ago](https://wordpress.org/support/topic/hide-empty-categories-in-shortcode/#post-18527069)
 * Thanks a lot

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

The topic ‘Hide empty categories in shortcode’ is closed to new replies.

 * ![](https://ps.w.org/wpadverts/assets/icon-256x256.png?rev=2423472)
 * [WPAdverts - Classifieds Plugin](https://wordpress.org/plugins/wpadverts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wpadverts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wpadverts/)
 * [Active Topics](https://wordpress.org/support/plugin/wpadverts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wpadverts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wpadverts/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [teeboy4real](https://wordpress.org/support/users/teeboy4real/)
 * Last activity: [10 months, 1 week ago](https://wordpress.org/support/topic/hide-empty-categories-in-shortcode/#post-18527069)
 * Status: resolved