\r\r<?php\r\r$category_id = get_query_var( 'cat' ); // Get current catgory ID\r$category = get_term( $category_id, 'category' ); // Fetch category term object\r\r// get_categories(['']);\r\r// Now, we check if the category has a parent\r// If it has, we use that ID\r// If it doesn't have a parent, it is a parent category itself and we use its own ID\r$parent = $category->parent ? $category->parent : $category_id; $args = array( 'show_count' => false, 'hide_empty' => false, 'title_li' => ", 'show_option_none' => ", 'echo' => false ); echo "parent: {$category->parent}"; // echo "category_id: $category_id"; // Show the children of parent category if ( $category->parent ) { $args['child_of'] = $category->parent; $args['exclude'] = $category_id; // Don't display the current category in this list } else { // $args['child_of'] = $category_id; } // $args['show_option_all'] = 'All'; $args['hide_empty'] = true; // Get the category list $categories_list = wp_list_categories( $args ); if ( $categories_list ) { ?>
\r
    \r<?php echo $categories_list; ?>\r
\r
\r<?php\r}\r\r?>\r\r<?php\rif ( have_posts() ) : ?>\r<?php\r/* Start the Loop */\rwhile ( have_posts() ) : the_post();\r\r/*\r* Include the Post-Format-specific template for the content.\r* If you want to override this in a child theme, then include a file\r* called content-___.php (where ___ is the Post Format name) and that will be used instead.\r*/\rget_template_part( 'template-parts/post/content', get_post_format() );\r\rendwhile;\r\rthe_posts_pagination( array(\r'prev_text' => twentyseventeen_get_svg( array( 'icon' => 'arrow-left' ) ) . '' . __( 'Previous page', 'twentyseventeen' ) . '', 'next_text' => '' . __( 'Next page', 'twentyseventeen' ) . '' . twentyseventeen_get_svg( array( 'icon' => 'arrow-right' ) ), 'before_page_number' => '' . __( 'Page', 'twentyseventeen' ) . '', ) ); else : get_template_part( 'template-parts/post/content', 'none' ); endif; ?>