//============================================================================== //WOOCOMMERCE - ARCHIVES - products with image first function custom_woocommerce_images_first_ordering_args( $q ) { $orderby_value…
Show Child Terms Shortcode
function enym_child_terms($atts)
{
// Attributes
$atts = shortcode_atts(
array(
'post_id' => '',
'taxonomy' => '',
),
$atts
);
//$terms = wp_get_post_terms( $atts['post_id'], $atts['taxonomy']);
//return count($terms);
$current_term_id = get_queried_object_id();
//Getting all the info of chilldren of the parent, not grandchildren
$termchildren = array(
'hierarchical' => 1,
'show_option_none' => '',
'hide_empty' => 1,
'parent' => $current_term_id,
'taxonomy' => 'product_cat'
);
$subcats = get_categories($termchildren);
// Display the children
echo '<nav class="vcex-navbar vcex-module no-margin vcex_662a1d35bdcce"><div class="vcex-navbar-inner wpex-clr wpex-last-mr-0">';
foreach ($subcats as $key => $value) {
$term_link = get_term_link($value);
$name = $value->name;
echo '<a href="' . $term_link . '" class="vcex-navbar-link vcex-navbar-link--821 wpex-block wpex-float-left wpex-mr-5 wpex-mb-5 theme-button flat wpex-text-base"><span class="vcex-navbar-link-text">' . $name . '</span></a>';
//echo '<a href="'.$term_link.'">'.$name.'</a>';
}
echo '</div></nav>';
}
add_shortcode('child_terms', 'enym_child_terms');
