Skip to content

Instantly share code, notes, and snippets.

@MinaPansuriya
Last active January 27, 2017 07:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MinaPansuriya/b63ada6878652c5fd01b6f2c69aa97a9 to your computer and use it in GitHub Desktop.
Save MinaPansuriya/b63ada6878652c5fd01b6f2c69aa97a9 to your computer and use it in GitHub Desktop.
/**
* @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