Get Category, Child Category and category Image Word Press
$args = array(
'hide_empty' => true,
'parent' => '0',
'meta_key' => 'exwoofood_menu_order',
'orderby' => 'meta_value_num',
);
$exwf_mngr = get_terms('product_cat', $args);
foreach ($exwf_mngr as $key => $value) {
$args = array(
'hide_empty' => true,
'parent' => $value->term_id
);
/// for child cat
$termss = get_terms( 'product_cat', $args );
$termscat_chils = '';
foreach ($termss as $key => $tsvalue) {
$termscat_chils .= $tsvalue->name.',';
}
$thumbnail_id = get_term_meta( $value->term_id, 'thumbnail_id', true );
if($thumbnail_id!=''){
// get the medium-sized image url
$image = wp_get_attachment_image_src( $thumbnail_id, 'full' );
// Output in img tag
if(isset($image[0]) && $image[0]!=''){
$icon_html = '<img src="' . $image[0] . '" alt="Packages" />';
}
}
}
Comments
Post a Comment