📚 文章归档
共 篇文章
暂无文章
query("SELECT id, title, slug, created_at FROM posts WHERE status = 'published' AND deleted_at IS NULL ORDER BY created_at DESC"); $all_posts = $result->fetch_all(MYSQLI_ASSOC); // Group by year and month $archives = []; foreach ($all_posts as $post) { $year = date('Y', strtotime($post['created_at'])); $month = date('m', strtotime($post['created_at'])); if (!isset($archives[$year])) { $archives[$year] = []; } if (!isset($archives[$year][$month])) { $archives[$year][$month] = []; } $archives[$year][$month][] = $post; } $categories = get_categories(); $recent_posts = get_recent_posts(5); include __DIR__ . '/header.php'; ?>