Get Link from the product category and display a list with the product subcategories of woocommerce

0

I use this code to display a list of sub categories of Wordpress posts, I wanted to know how I would instead of picking up the category of posts I pick up in the category of Woocommerce products.

        <!-- CATEGORIA -->
    <?php $id_da_categoria = get_cat_id('nome da categoria'); 
    $link_da_categoria = get_category_link($id_da_categoria); ?>
    <a href="<?php echo $link_da_categoria ;?>"> CATEGORIA </a>

    <ul>
        <!-- Exibe as sub categorias em uma lista -->
        <?php
        $id_da_categoria = get_cat_id('categoria');
        wp_list_categories('sort_column=name&child_of='."$id_da_categoria".'&title_li=');
        ?>
    </ul>
    
asked by anonymous 11.05.2016 / 14:32

1 answer

1

You can list the categories using the get_categories() function, and pass the taxonomy parameter to product_cat .

Example:

<?php

  $taxonomy     = 'product_cat';
  $orderby      = 'name';

  $args = array('taxonomy' => $taxonomy, 'orderby' => $orderby);

  $product_categories = get_categories( $args );

?>
    
11.05.2016 / 20:03