function prod_cat_menu_shortcode(){
    ob_start();
    $taxonomy = 'product-cat';
    // 获取顶级分类（父ID=0）
    $top_terms = get_terms(array(
        'taxonomy' => $taxonomy,
        'parent' => 0,
        'hide_empty' => true
    ));

    if(!empty($top_terms) && !is_wp_error($top_terms)){
        echo '<ul style="list-style:none; padding:0; margin:0;">';
        foreach($top_terms as $t){
            $link = get_term_link($t);
            echo '<li style="border-bottom:1px solid #eee;">
                <a href="'.$link.'" style="display:block; padding:12px 8px; color:#333; text-decoration:none;">'.$t->name.'</a>';
            // 调取子分类
            $childs = get_terms(array(
                'taxonomy' => $taxonomy,
                'parent' => $t->term_id,
                'hide_empty' => true
            ));
            if(!empty($childs) && !is_wp_error($childs)){
                echo '<ul style="list-style:none; padding:0 0 0 16px; margin:0;">';
                foreach($childs as $c){
                    $clink = get_term_link($c);
                    echo '<li style="border-bottom:1px solid #f4f4f4;">
                        <a href="'.$clink.'" style="display:block; padding:10px 8px; color:#666; text-decoration:none; font-size:14px;">'.$c->name.'</a>
                    </li>';
                }
                echo '</ul>';
            }
            echo '</li>';
        }
        echo '</ul>';
    }else{
        echo '<p>暂无产品分类，请先在后台添加分类</p>';
    }
    return ob_get_clean();
}
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://test.szshouyiren.com/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://test.szshouyiren.com/wp-sitemap-posts-post-1.xml</loc></sitemap><sitemap><loc>https://test.szshouyiren.com/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://test.szshouyiren.com/wp-sitemap-posts-product-1.xml</loc></sitemap><sitemap><loc>https://test.szshouyiren.com/wp-sitemap-taxonomies-category-1.xml</loc></sitemap><sitemap><loc>https://test.szshouyiren.com/wp-sitemap-taxonomies-product-cat-1.xml</loc></sitemap><sitemap><loc>https://test.szshouyiren.com/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
