<?php
/*
* function.php
*/
function woocommerce_subcats_from_parentcat_by_ID($parent_cat_ID) {
$args = array(
'hierarchical' => 1,
'show_option_none' => '',
'hide_empty' => 0,
'parent' => $parent_cat_ID,
'taxonomy' => 'product_cat'
);
$subcats = get_categories($args);
echo '<ul class="wooc_sclist">';
$cant = count($subcats);
$i = 1;
foreach ($subcats as $sc) {
$link = get_term_link( $sc->slug, $sc->taxonomy );
echo '<li><a href="'. $link .'">'.$sc->name.'</a></li>';
$i++;
}
echo '</ul>';
}
?>
<?php
/*
* Template: wherever you wish to use
*/
$cate = get_queried_object();
$cat = $cate->term_id;
woocommerce_subcats_from_parentcat_by_ID($cat);
?>
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.