• So i have a category name “living” under that category i have child categories such as
    Potpourri
    In the Home
    Family and Relationships
    In the Kitchen

    i have the code below that will output the child categories when viewing the parent category

    however i would like to be able to click on any of these child categories and still see the above child categories (sibling categories) so that my users can navigate easily without having to go back

    		<?php 
    if ( is_category() ) {
    $this_category = get_category($cat);
    if($this_category->category_child):
    else:
       $this_category = wp_list_categories('orderby=id&depth=1&show_count=0&hide_empty=0&title_li=&use_desc_for_title=1&child_of='.$this_category->cat_ID."&echo=0");
    echo '
    <ul>
    
    '. $this_category . '</ul>';
    endif;
    } 
    			?>
Viewing 1 replies (of 1 total)
  • I think you want something like this (untested):

    
    if ( is_category() ) {
        $this_category = get_category( $cat );
        $category_parent = $this_category->category_parent();
        if ( $category_parent ) {
            wp_list_categories( [ 'child_of' => $category_parent->term_id ] );
        }
    }
    
Viewing 1 replies (of 1 total)
  • The topic ‘sibling categories’ is closed to new replies.