Title: Hide shortcode class when no content
Last modified: October 31, 2017

---

# Hide shortcode class when no content

 *  Resolved [harf4ng](https://wordpress.org/support/users/harf4ng/)
 * (@harf4ng)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/hide-shortcode-class-when-no-content/)
 * Hi,
 * On my website I’m using the “product-category” shortcode like this:
    [product_category
   category=”entrepots” per_page=”12″ columns=”4″ orderby=”date” order=”desc” class
   =”product-entrepots”]
 * I have put a class on this, so then I could use this kind of stuff to add a title
   for my products:
 *     ```
       .product-entrepots:before {
         content: "Nos entrepôts :";
         font-weight: bold;
       }
       ```
   
 * My problem is, if there is no product in the given category, the title is still
   displayed. The only workaround I found was to put a display none in my css when
   there is no product, but then I have to consider myself if there are products
   in the category or not.
 * Isn’t there a way to not display the class at all if there is no product in the
   category?
 * Thanks

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

 *  Plugin Support [Riaan K.](https://wordpress.org/support/users/riaanknoetze/)
 * (@riaanknoetze)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/hide-shortcode-class-when-no-content/#post-9688891)
 * You’d need to alter the `body_classes` function by first checking whether the
   WooCommerce loop found any products.
 * Your best bet would be to get in touch with a web developer to create that for
   you or perhaps with one of the Woo Experts at [https://woocommerce.com/customization/](https://woocommerce.com/customization/)
 *  [Erina (a11n)](https://wordpress.org/support/users/eri32s98/)
 * (@eri32s98)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/hide-shortcode-class-when-no-content/#post-9731912)
 * We haven’t heard back from you in a while, so I’m going to mark this as resolved.
   If you have any further questions, you can start a new thread.

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

The topic ‘Hide shortcode class when no content’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * 2 replies
 * 3 participants
 * Last reply from: [Erina (a11n)](https://wordpress.org/support/users/eri32s98/)
 * Last activity: [8 years, 5 months ago](https://wordpress.org/support/topic/hide-shortcode-class-when-no-content/#post-9731912)
 * Status: resolved