Site icon Hip-Hop Website Design and Development

Show youngsters of the class a publish is assigned to

The next code works to show all youngster classes of a guardian (when viewing a guardian class), and all siblings of a kid class (when viewing a toddler class) inside sidebar.php. The identical sidebar is pulled into each posts and pages.

I would wish to take it a step additional so it additionally works when viewing a publish, as a substitute of solely classes and youngster classes. On a publish, I would like all youngster classes of the class assigned to a publish to show. After spending numerous hours, I am at a loss. Can anybody assist me with this?

    <ul>                
            <?php if (is_category( )) {                             
                  $cat = get_query_var('cat');
                  $thiscat = get_category ($cat);
                  $guardian = $thiscat->guardian;
                  $img = get_option('z_taxonomy_image' . $thiscat->term_id);

                  if ($guardian != '') {

                        wp_list_categories( array(
                        'child_of' => $guardian,
                        'exclude' => $cat,
                        'title_li' => 0
                    ) );
                    }

                  else {

                        wp_list_categories( array(
                        'child_of' => $cat,
                        'title_li' => 0
                    ) );
                  }

            } 
            ?>

            </ul>