0

I am using the below codes to show all Parent Terms from a custom taxonomy with title and link on a page. But I want to show the parent term description, thumbnail and post count in it too. So how I can get those too (alongside title and link)?

$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 ) {
    if ( $cat->category_parent == 0 ) {
        $category_id = $cat->term_id;
        echo '<br /><a href="'. get_term_link($cat->slug, 'product_cat') .'">'. $cat->name .'</a>'; ?>
    } 
}

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.

0

I was trying after posting here too and I got my snippet and here I am also sharing it so you can also get it. I used the code shared at Display WooCommerce Products Categories With Thumbnail & Description. It also shows Title, Link, Product Count In It, Thumbnail, Description and Custom Text so this is my solution. Hope you will find it worthy too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.