-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathproduct-categories.php
45 lines (41 loc) · 1010 Bytes
/
product-categories.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/*
* Template Name: Product Categories
*/
get_header();
?>
<?php //echo do_shortcode( '[product_categories]' );?>
<?php
$args = array(
'taxonomy' => 'product_cat',
'hide_empty' => false,
);
$result = get_terms( $args );
?>
<div class="container">
<div class="row">
<?php
foreach ( $result as $cat ) {
if ( 'Uncategorized' !== $cat->name ) {
$term_link = get_term_link( $cat, 'product_cat' );
$cat_thumb_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true );
$shop_catalog_img_arr = wp_get_attachment_image_src( $cat_thumb_id, 'shop_catalog' );
$cat_img = $shop_catalog_img_arr[0];
?>
<div class="col-md-4">
<div>
<a href="<?php echo $term_link; ?>"><img src="<?php echo $cat_img; ?>" alt=""></a>
</div>
<div>
<a href="<?php echo $term_link; ?>">
<?php echo $cat->name; ?><span>( <?php echo $cat->count;?> )</span>
</a>
</div>
</div>
<?php
}
}
?>
</div>
</div>
<?php get_footer(); ?>