Title: Default Category
Last modified: November 3, 2017

---

# Default Category

 *  Resolved [Rneo83](https://wordpress.org/support/users/rneo83/)
 * (@rneo83)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/default-category-12/)
 * How to set Default Category in product ?

Viewing 1 replies (of 1 total)

 *  Plugin Author [ndre](https://wordpress.org/support/users/ndre/)
 * (@ndre)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/default-category-12/#post-9656253)
 * Hello [@rneo83](https://wordpress.org/support/users/rneo83/),
 * You can use the following code to set the default product category:
 *     ```
       add_action( 'product_edit_save', 'my_default_product_category' );
   
       function my_default_product_category( $post ) {
          if ( 'publish' === $post->post_status ) {
             $default_category = 'my-default-category-slug';
             $terms = wp_get_post_terms( $post->ID, 'al_product-cat' );
             if ( empty( $terms ) ) {
                wp_set_object_terms( $post->ID, $default_category, 'al_product-cat' );
             }
          }
       }
       ```
   
 * You should replace my-default-category-slug with your selected category slug.

Viewing 1 replies (of 1 total)

The topic ‘Default Category’ is closed to new replies.

 * ![](https://ps.w.org/ecommerce-product-catalog/assets/icon-128x128.png?rev=1103243)
 * [eCommerce Product Catalog Plugin for WordPress](https://wordpress.org/plugins/ecommerce-product-catalog/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ecommerce-product-catalog/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ecommerce-product-catalog/)
 * [Active Topics](https://wordpress.org/support/plugin/ecommerce-product-catalog/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ecommerce-product-catalog/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ecommerce-product-catalog/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [ndre](https://wordpress.org/support/users/ndre/)
 * Last activity: [8 years, 5 months ago](https://wordpress.org/support/topic/default-category-12/#post-9656253)
 * Status: resolved