Get list of all WooCommerce categories.


$orderby = 'name';
$order = 'asc';
$hide_empty = false ;
$cat_args = array(
    'orderby'    => $orderby,
    'order'      => $order,
    'hide_empty' => $hide_empty,
);

$product_categories = get_terms( 'product_cat', $cat_args );

if( !empty($product_categories) ){
	echo '<ul>';
	foreach ($product_categories as $key => $category) {
		echo '<li>';
		echo '<a href="'.get_term_link($category).'" >';
		echo $category->name;
		echo '</a>';
		echo '<li>';
	}
	echo '</ul>';
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s