Title: simpsonb's Replies | WordPress.org

---

# simpsonb

  [  ](https://wordpress.org/support/users/simpsonb/)

 *   [Profile](https://wordpress.org/support/users/simpsonb/)
 *   [Topics Started](https://wordpress.org/support/users/simpsonb/topics/)
 *   [Replies Created](https://wordpress.org/support/users/simpsonb/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/simpsonb/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/simpsonb/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/simpsonb/engagements/)
 *   [Favorites](https://wordpress.org/support/users/simpsonb/favorites/)

 Search replies:

## Forum Replies Created

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

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Products created with REST API don’t display in subcategory archive](https://wordpress.org/support/topic/products-created-with-rest-api-dont-display-in-subcategory-archive/)
 *  [simpsonb](https://wordpress.org/support/users/simpsonb/)
 * (@simpsonb)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/products-created-with-rest-api-dont-display-in-subcategory-archive/#post-13908796)
 * I’m getting this problem as well when trying to set products to ANY categories
   via the REST API. If I go to the WP product editor, the product shows the categories
   exactly as I set them with the API but does not show up on the category page 
   or in the shop page when filtering by category. If I just hit the update button(
   I don’t actually change anything at all) from the WP product editor, it then 
   shows up as expected under the category pages and when filtering.
 * Couple things I noticed:
    – The response when updating via REST API and the response
   from a GET request after manually hitting the update button in WP product editor
   are exactly the same except that the GET response lists the ID of the other products
   in that category under “related_ids”: [] and put a <p>…</p>\n around the “short_description”:””–
   The product count is only increased by 1 in the specific categories that were
   set via the REST API. Any parent category counts are not increased by 1 until
   I manually hit the update button in the WP product editor. I’ve tried making 
   the REST API set the product to any parent categories of the desired subcategory
   but that doesn’t work.
 * This leads me to believe that updating a product via the REST API isn’t triggering
   woocommerce to regenerate the product and update any counts as it should and 
   does when you hit the update button in the WP product editor.
 * As for how to fix it, I have no idea yet… I’ve wasted 2 days trying to get this
   to work thinking it’s an issue with my API request. It is not. Guess it’s time
   to start digging through the core files but would love an idea about where to
   start, like if there is a hook or function called normally to process the regeneration.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Display subcategory list under main category thumbnail](https://wordpress.org/support/topic/display-subcategory-list-under-main-category-thumbnail/)
 *  Thread Starter [simpsonb](https://wordpress.org/support/users/simpsonb/)
 * (@simpsonb)
 * [6 years ago](https://wordpress.org/support/topic/display-subcategory-list-under-main-category-thumbnail/#post-12774581)
 * Ok so after some more searching online and using the right combination of search
   terms I stumbled across this guide here:
 * [https://www.themelocation.com/how-to-display-all-the-subcategories-from-a-specific-category-in-woocommerce/](https://www.themelocation.com/how-to-display-all-the-subcategories-from-a-specific-category-in-woocommerce/)
 * From that guide I created this snippet of code that can be added to your theme’s
   functions.php file so that the subcategory list appears under the main category
   title in the main categories loop. No modification of the content-product-cat.
   php template needed. So if anybody else needs the code here it is:
 *     ```
       // Adding Child Category List to Main Category Display Grid
   
       add_action('woocommerce_after_subcategory_title', 'woocommerce_subcats_from_parentcat_by_ID', 20);
   
       function woocommerce_subcats_from_parentcat_by_ID($category) {
       	$parent_category_ID = $category->term_id;
       	$args = array(
       		'hierarchical' => 1,
       		'show_option_none' => '',
       		'hide_empty' => 0, // Set to 0 to show empty categories and 1 to hide them
       		'parent' => $parent_category_ID,
       		'taxonomy' => 'product_cat'
       	);
       	$subcategories = get_categories($args);
       	echo '<ul class="woo_subcategory_list">';
       	foreach ($subcategories as $subcategory) {
       		$link = get_term_link( $subcategory->slug, $subcategory->taxonomy );
       		echo '<li><a href="'. $link .'">'.$subcategory->name.'</a></li>';
       	}
       	echo '</ul>';
       }
       ```
   

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