I'm trying to write a php code on my index file in wordpress. I have to get the images & names of each category, this is what I've got so far:
$term = get_queried_object()->term_id;
$termid = get_term($term, 'product_cat' );
$args = array(
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => false,
'child_of' => $term,
'parent' =>0
);
$subproducts = get_terms( 'product_cat', $args);
foreach ($subproducts as $subproduct) {
echo $subproduct->name.'<br>';
echo $subproduct->term_id; //get the category Id
}
How do I get the category image url?