Skip to main content

get all woocommerce categories

 <?php
                    $args = array(
                        'taxonomy'   => "product_cat",
                        'orderby'    => 'name',
                        'order' => 'DESC',
                    );
                    $product_categories = get_terms($args);
                    foreach ( $product_categories as $cat )
                    {
                        //dd($cat,'fdf');
                        $term_id      = $cat->term_id;
                        if ( $term_id != 19 )
                        {
                        $thumbnail_id = get_woocommerce_term_meta( $term_id, 'thumbnail_id', true );
                        $image        = wp_get_attachment_url( $thumbnail_id ,'thumbnail');
                        $category_link = get_category_link( $term_id );
                ?>
                    <!--first-->
                    <div class="col-sm-3">
                       <div class="gd-collection-wrapper mb-5">
                          <figure class="gd-single-image">
                             <img src="<?php echo $image; ?>" />
                          </figure>
                          <div class="text-center">
                             <a href="<?php echo $category_link; ?>" class="gd-collection-pro-text"><?php echo $cat->name; ?></a>
                          </div>
                       </div>
                    </div>
                    <!--first-->
                <?php    }
                    }    
            ?>

Comments

Popular posts from this blog

add custom post type

/**  *  * add custom post type  *  */ function my_custom_post_product() {   $labels = array(     'name'               => _x( 'Products', 'post type general name' ),     'singular_name'      => _x( 'Product', 'post type singular name' ),     'add_new'            => _x( 'Add New', 'book' ),     'add_new_item'       => __( 'Add New Product' ),     'edit_item'          => __( 'Edit Product' ),     'new_item'           => __( 'New Product' ),     'all_items'          => __( 'All Products' ),     'vi...

Toolset conditional

[wpv- if evaluate= "'[wpv-current-user info='id']' = '[wpv-post-author format='meta' meta='ID']' OR '[wpv-current-user info='role']' = 'administrator'" ]      //the content you want to hide goes here [/wpv- if ]