', 'after' => '
', ]); echo ''category', 'hide_empty' => false, 'orderby' => 'term_group', 'order' => 'ASC', ]); if (is_wp_error($all_terms)) { $all_terms = []; } $top_level = []; $children_by_parent = []; foreach ($all_terms as $term) { $parent_id = (int) $term->parent; if ($parent_id === 0) { $top_level[] = $term; } else { $children_by_parent[$parent_id][] = $term; } } $total_posts = wp_count_posts('post'); $total_posts = $total_posts && isset($total_posts->publish) ? (int) $total_posts->publish : 0; $page_title = trim((string) get_the_title($post_id)); $page_title = $page_title !== '' ? $page_title : __('分类目录', 'jio'); $has_sidebar = function_exists('jio_archive_has_sidebar') ? jio_archive_has_sidebar() : (function_exists('jio_is_show_sidebar') ? jio_is_show_sidebar() : false); $content_style = sanitize_key((string) get_post_meta($post_id, 'page_content_style', true)); if (!in_array($content_style, ['', 'not', 'nobox', 'full'], true)) { $content_style = ''; } $content_style_class = $content_style !== '' ? ' page-content-' . $content_style : ' page-content-default'; $render_children = static function (int $parent_id, array $path) use (&$render_children, $children_by_parent): string { $children = $children_by_parent[$parent_id] ?? []; if ($children === []) { return ''; } $html = '
' . esc_html(wp_trim_words($description, 18, '…')) . '
'; } $nested = $render_children($child_id, array_merge($path, [$child_id])); if ($nested !== '') { $html .= $nested; } $html .= '', 'after' => '
', ]); echo '