taxonomy – Display sibling categories on category page

Question

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 assume, but how i exclude existing category i am on from this list. Hope it makes sense:) Please help anyone?

0
Alex Osipov 10 months 2022-01-17T19:14:09-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse