Skip to content

Instantly share code, notes, and snippets.

@diggeddy
Created April 20, 2020 17:31
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 diggeddy/88f12fc35ecd3f0730203e8be382eddd to your computer and use it in GitHub Desktop.
Save diggeddy/88f12fc35ecd3f0730203e8be382eddd to your computer and use it in GitHub Desktop.
<?php
$cat_args = array(
'orderby' => 'name',
'order' => 'asc',
'hide_empty' => true,
);
$product_categories = get_terms( 'product_cat', $cat_args );
if ( ! empty( $product_categories ) ) {
echo '<ul class="woo-cat-nav">';
foreach ( $product_categories as $key => $category ) {
printf(
'<li>
<a href="%1$s">
%2$s
</a>
</li>',
get_term_link( $category ),
$category->name
);
}
echo '</ul>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment