Last active
January 27, 2017 07:34
-
-
Save MinaPansuriya/b63ada6878652c5fd01b6f2c69aa97a9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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