Я сделал это сам, но в подкатегориях не работают изображения:
<div id="kategorie-nahlad">
<?php
$taxonomy = 'product_cat';
$orderby = 'name';
$show_count = 0;
$pad_counts = 0;
$hierarchical = 1;
$title = '';
$empty = 0;
$args = array(
'taxonomy' => $taxonomy,
'orderby' => $orderby,
'show_count' => $show_count,
'pad_counts' => $pad_counts,
'hierarchical' => $hierarchical,
'title_li' => $title,
'hide_empty' => $empty
);
$all_categories = get_categories( $args ); ?>
<div id="owl1" class="owl-carousel">
<?
foreach ($all_categories as $cat) {
$thumbnail_id = get_term_meta( $cat->term_id, 'thumbnail_id', true );
$image = wp_get_attachment_url( $thumbnail_id );
$image_alt = get_post_meta( $image->id, '_wp_attachment_image_alt', true );
if ($cat->category_parent == 0) {
$category_id = $cat->term_id;
echo '<div class="item text-center">';
echo '<br><a href="'. get_term_link($cat->slug, 'product_cat') .'"><img src="' . $image . '" alt="' . $image_alt . '">'. $cat->name .'</a>';
echo '</div>';
$args2 = array(
'taxonomy' => $taxonomy,
'child_of' => 0,
'parent' => $category_id,
'orderby' => $orderby,
'show_count' => $show_count,
'pad_counts' => $pad_counts,
'hierarchical' => $hierarchical,
'title_li' => $title,
'hide_empty' => $empty
);
$sub_cats = get_categories( $args2 );
if($sub_cats) {
foreach($sub_cats as $sub_category) {
$thumbnail_id_sub = get_term_meta( $cat->term_id, 'thumbnail_id', true );
$image_sub = wp_get_attachment_url( $thumbnail_id_sub );
echo '<div class="item text-center">';
echo '<br><a href="'. get_term_link($sub_category->slug, 'product_cat') .'"><img src="' . $image . '" alt="' . $image_alt . '">'. $sub_category->name .'</a>';
// echo apply_filters( 'woocommerce_subcategory_count_html', ' <div class="cat-count">' . $sub_category->count . '</div>', $category );
echo '</div>';
}
}
}
}
?>
</div><!-- KONIEC OWL1 -->
</div>