Skip to content

Instantly share code, notes, and snippets.

@steroyle
Last active October 3, 2018 18:26
Show Gist options
  • Save steroyle/a6bffc5ccf7245955327a66b1b76b013 to your computer and use it in GitHub Desktop.
Save steroyle/a6bffc5ccf7245955327a66b1b76b013 to your computer and use it in GitHub Desktop.
WooCommerce Categories Loop
<?php
$categories = get_categories(
array(
'taxonomy' => 'product_cat',
'orderby' => 'name',
'hide_empty' => '0'
)
);
?>
<ul class="categories">
<?php foreach($categories as $category): ?>
<li class="category">
<p>ID: <?php echo $category->term_id; ?></p>
<p>Name: <?php echo $category->name; ?></p>
<p>Slug: <?php echo $category->slug; ?></p>
<p>Image URL: <?php echo wp_get_attachment_url(get_woocommerce_term_meta($category->term_id, 'thumbnail_id', true )); ?></p>
<p>Link: <?php echo get_category_link($category->term_id); ?></p>
</li>
<?php endforeach; ?>
<ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment