Support » Plugin: WooCommerce » [Plugin: WooCommerce – excelling eCommerce] Category List?

  • This is probably really simple … and I’m just being thick but I’ve been battling it for a couple of hours now so I’m hoping someone can assist 🙂

    I’m trying to generate a list of all Shop Categories … I see that the taxonomy name is “product_cat” … so this code should pull a list of them or am I ‘doin it rong’ ?

    <?php
    $args=array(
      'name' => 'product_cat'
    );
    $output = 'objects'; // or objects
    $taxonomies=get_taxonomies($args,$output);
    if  ($taxonomies) {
      foreach ($taxonomies  as $taxonomy ) {
        echo '<p>' . $taxonomy->name . '</p>';
      }
    }
    ?>

    http://wordpress.org/extend/plugins/woocommerce/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Typically I found the answer moments later …

    <?php
    //list terms in a given taxonomy using wp_list_categories (also useful as a widget if using a PHP Code plugin)
    
    $taxonomy     = 'genre';
    $orderby      = 'name';
    $show_count   = 0;      // 1 for yes, 0 for no
    $pad_counts   = 0;      // 1 for yes, 0 for no
    $hierarchical = 1;      // 1 for yes, 0 for no
    $title        = '';
    
    $args = array(
      'taxonomy'     => $taxonomy,
      'orderby'      => $orderby,
      'show_count'   => $show_count,
      'pad_counts'   => $pad_counts,
      'hierarchical' => $hierarchical,
      'title_li'     => $title
    );
    ?>
    
    <ul>
    <?php wp_list_categories( $args ); ?>
    </ul>

    Great post Mithadriel. I want to do the same thing with a site I am working on; though I am interested in adding the product category list with links to products w/in that category.

    My question to you is, which file are you modifying with the code above to get the list to print?

    Thanks for you post and in advance for any additional info you can share 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: WooCommerce – excelling eCommerce] Category List?’ is closed to new replies.