F
F
freeman02042017-10-13 18:08:48
PHP
freeman0204, 2017-10-13 18:08:48

How to display category thumbnail in wordpress woocommerce on homepage?

Now I have retrieved the product_cat taxonomy via get_categories. And it turned out to display the name of the category. How to display an image? How I attached the thumbnail image prntscr.com/gwzmpn

<div class="row">
                <?php
                $all_categories = get_categories(array(
                    'taxonomy'     => 'product_cat',
                    'orderby'      => 'name',
                    'show_count'   => 0,
                    'pad_counts'   => 0,
                    'hierarchical' => 1,
                    'title_li'     => '',
                    'hide_empty'   => 0
                ));
                foreach ($all_categories as $cat) : ?>
                    <div class="col-lg-3 col-md-6 col-sm-6 m-bottom">
                        <div class="box_reducers">
                            <div class="wrap_img">
                                <img src="../images/reduct.png">
                            </div>
                            <?php
                             $category_name = $cat->name;
                             echo '<a href="'. get_term_link($cat->slug, 'product_cat') .'">'. $cat->name .'</a>';
                             ?>
                        </div>
                    </div>
                <? endforeach; ?>
            </div>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question