public function add_product_image_as_woocommerce_subcategory_thumbnail($category)
 {
     if ($this->let_category_image_override) {
         if (get_woocommerce_term_meta($category->term_id, 'thumbnail_id', true)) {
             woocommerce_subcategory_thumbnail($category);
             return;
         }
     }
     $query_args = array('posts_per_page' => $this->randomize_category_image_from_products ? 10 : 1, 'post_status' => 'publish', 'post_type' => 'product', 'meta_query' => array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')), 'tax_query' => array(array('taxonomy' => 'product_cat', 'field' => 'id', 'terms' => $category->term_id)));
     $products = get_posts($query_args);
     if ($products) {
         echo get_the_post_thumbnail($products[array_rand($products)]->ID, 'shop_thumbnail');
         echo get_the_post_thumbnail($products[array_rand($products)]->ID, 'shop_thumbnail');
         echo get_the_post_thumbnail($products[array_rand($products)]->ID, 'shop_thumbnail');
         echo get_the_post_thumbnail($products[array_rand($products)]->ID, 'shop_thumbnail');
         echo get_the_post_thumbnail($products[array_rand($products)]->ID, 'shop_thumbnail');
     }
 }
 /**
  * Display woocommerce_subcategory_thumbnail() wrapped with 'a' targ.
  * 
  * @param  mixed $category
  * @param  string $class
  */
 function dt_woocommerce_subcategory_thumbnail($category, $class = '')
 {
     ob_start();
     woocommerce_subcategory_thumbnail($category);
     $img = ob_get_contents();
     ob_end_clean();
     $img = str_replace('<img', '<img class="preload-me"', $img);
     echo '<a href="' . get_term_link($category->slug, 'product_cat') . '" class="' . esc_attr($class) . '">' . $img . '</a>';
 }
	<?php 
/**
 * woocommerce_before_subcategory hook.
 *
 * @hooked woocommerce_template_loop_category_link_open - 10
 */
do_action('woocommerce_before_subcategory', $category);
/**
 * woocommerce_before_subcategory_title hook.
 *
 * @hooked woocommerce_subcategory_thumbnail - 10
 */
do_action('woocommerce_before_subcategory_title', $category);
if ($img_ratio == 'off') {
    woocommerce_subcategory_thumbnail();
} else {
    $thumbnail_id = get_woocommerce_term_meta($category->term_id, 'thumbnail_id', true);
    if ($thumbnail_id) {
        $image_cat_url = wp_get_attachment_image_src($thumbnail_id, 'full');
        $image_cat_url = $image_cat_url[0];
        $cat_image = aq_resize($image_cat_url, $catimgwidth, $catimgheight, true);
        if (empty($cat_image)) {
            $cat_image = $image_cat_url;
        }
    } else {
        $cat_image = virtue_img_placeholder();
    }
    if ($cat_image) {
        echo '<img src="' . esc_url($cat_image) . '" width="' . esc_attr($catimgwidth) . '" height="' . esc_attr($catimgheight) . '" alt="' . esc_attr($category->name) . '" />';
    }
Exemple #4
0
 public function subcategory_thumbnail_wrapper($category)
 {
     echo '<figure class="entry-featured-media">';
     echo '<a href="' . get_term_link($category->slug, 'product_cat') . '" class="g1-frame g1-frame--none g1-frame--inherit g1-frame--center">';
     echo '<span class="g1-decorator">';
     woocommerce_subcategory_thumbnail($category);
     echo '<span class="g1-indicator g1-indicator-document"></span>';
     echo '</span>';
     echo '</a>';
     echo '</figure>';
 }
				<?php 
$args = array('taxonomy' => 'product_cat', 'orderby' => 'name', 'show_count' => 0, 'pad_counts' => 0, 'hierarchical' => 1, 'title_li' => '', 'hide_empty' => 0, 'exclude' => 19);
?>
				<?php 
$all_categories = get_categories($args);
//print_r($all_categories);
foreach ($all_categories as $cat) {
    //print_r($cat);
    if ($cat->category_parent == 0) {
        $category_id = $cat->term_id;
        ?>
			 
				<div class="cate">
					<?php 
        echo '<a href="' . get_term_link($cat->slug, 'product_cat') . '">' . '<div class="cat-cont c-b">';
        echo '<div class="cat-img">' . woocommerce_subcategory_thumbnail($cat) . '</div>';
        echo '<span class="cat-nombre">' . $cat->name . '</span>';
        echo '<div class="cat-desc"><span>' . $cat->description . '</span></div>';
        echo '</div></a>';
        ?>
				</div>
	    			<?php 
    }
}
?>
			</div> <!-- FIN ROW -->
		</div> <!-- FIN CONTAINER -->
		
		

		<div class="container">