To display categories above the list of products, you need to enable this checkbox in the WooCommerce settings, but then the categories will be displayed the same as the products, there will be no separator between categories and products.
The following code makes it possible, with the “Show products only” option enabled in the WooCommerce settings, to display categories separately above the list of products:
function nepoladoknet_product_subcategories( $args = array() ) { $parentid = get_queried_object_id(); $args = array( 'parent' => $parentid ); $terms = get_terms( 'product_cat', $args ); if ( $terms ) { echo '<ul class="product-cats">'; foreach ( $terms as $term ) { echo '<li class="category">'; echo '<a href="' . esc_url( get_term_link( $term ) ) . '" class="' . $term->slug . '">'; woocommerce_subcategory_thumbnail( $term ); echo '<p>'.$term->name.'</p>'; echo '</a>'; } echo '</ul>'; } } add_action( 'woocommerce_before_shop_loop', 'nepoladoknet_product_subcategories', 50 );