samedi 29 novembre 2014

WooCommerce Product Categories With Description And Thumbnail


I am using the below codes to show all WooCommerece Parent Products categories with title and link on a page. But I want to show WooCommerece Parent Products categories description, thumbnail and post count in it too. So how I can get those too along title and link.



<?php
$taxonomy = 'product_cat';
$orderby = 'name';
$show_count = 0; // 1 for yes, 0 for no
$pad_counts = 0; // 1 for yes, 0 for no
$hierarchical = 1; // 1 for yes, 0 for no
$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
);
?>
<?php $all_categories = get_categories( $args );
foreach ($all_categories as $cat) {
if($cat->category_parent == 0) {
$category_id = $cat->term_id;
?>
<?php echo '<br /><a href="'. get_term_link($cat->slug, 'product_cat') .'">'. $cat->name .'</a>'; ?>
<?php
}
}
?>


Note: I will give warm welcome to those who also help me to short the upper code more as I think it have some extra stuff...





Aucun commentaire:

Enregistrer un commentaire