Instantly share code, notes, and snippets.

Embed
What would you like to do?
/**
* @Title: Woocommerce - List All Categories
* @Author: Mina Pansuriya
* @Website: http://minapansuriya.com
* @Blog URL: http://minapansuriya.com/woocommerce-list-all-categories/
*/
<?php
$args = array(
'taxonomy' => 'product_cat',
'orderby' => 'name',
'hierarchical' => 1,
'hide_empty' => 0 // Use 1 to hide empty categories.
);
$all_categories = get_categories( $args );
?>
<ul>
<?php
foreach ($all_categories as $cat) {
?>
<li><a href="<?php echo get_term_link($cat->slug, 'product_cat'); ?>"><?php echo $cat->name; ?></a></li>
<?php
} ?>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment