I have a category page, how do i display this category sibling categories on this page as well? I know how to display children categories:
<ul class="slider-container-list sub-categories-block front-categories-block front-categories-scroll">
<?php
$term = get_queried_object();
$children = get_terms( $term->taxonomy, array(
'parent' => $term->term_id,
'hide_empty' => false
) );
if ( $children ) {
foreach( $children as $subcat ){
echo '<li class="category-thumbnail-item"><a class="category-thumbnail" href="' . esc_url(get_term_link($subcat, $subcat->taxonomy)) . '">';
echo '<div class="category-thumbnail-image"><img src="' . z_taxonomy_image_url($subcat->term_id, 'medium'). '" data-pin-nopin="true" alt="'. $subcat->name .' Sub Category Image"> </div>';
echo '<div class="category-title">' . $subcat->name . '</div></a></li>';
}
}
?>
</ul>
Now i am trying to figure out how to display siblingsā¦ Should i call parent ID and children after? I think i need to get term_id somehow, i am sure i am missing something:(
<ul class="slider-container-list sub-categories-block front-categories-block front-categories-scroll">
<?php
$term_id = 10;
$taxonomy_name = 'products';
$termchildren = get_term_children( $term_id, $taxonomy_name );
if ( $termchildren ) {
foreach ( $termchildren as $child ){
echo '<li class="category-thumbnail-item"><a class="category-thumbnail" href="' . esc_url(get_term_link($child, $child->taxonomy)) . '">';
echo '<div class="category-thumbnail-image"><img src="' . z_taxonomy_image_url($child->term_id, 'medium'). '" data-pin-nopin="true" alt="'. $child->name .' Sub Category Image"> </div>';
echo '<div class="category-title">' . $child->name . '</div></a></li>';
}
}
?>
</ul>
i assume, but how i exclude existing category i am on from this list. Hope it makes sense:) Please help anyone?