Initial commit: TechBlog Pro WordPress theme
Features: - Modern UI with dark mode support - Code highlighting with copy button - Auto table of contents - Reading time & views counter - Responsive design - Admin settings page - AJAX search
This commit is contained in:
Executable
+143
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
/**
|
||||
* Archive Template
|
||||
*
|
||||
* @package TechBlog Pro
|
||||
*/
|
||||
|
||||
get_header();
|
||||
?>
|
||||
|
||||
<!-- Archive Header -->
|
||||
<div class="archive-header" style="margin-bottom: 32px;">
|
||||
<?php if (is_category()) : ?>
|
||||
<h1 style="font-size: 1.75rem; font-weight: 700; margin-bottom: 8px;">
|
||||
📂 <?php single_cat_title(); ?>
|
||||
</h1>
|
||||
<?php if (category_description()) : ?>
|
||||
<p style="color: var(--text-secondary);"><?php echo category_description(); ?></p>
|
||||
<?php endif; ?>
|
||||
<p style="color: var(--text-muted); font-size: 0.9375rem;">
|
||||
共 <?php echo $wp_query->found_posts; ?> 篇文章
|
||||
</p>
|
||||
|
||||
<?php elseif (is_tag()) : ?>
|
||||
<h1 style="font-size: 1.75rem; font-weight: 700; margin-bottom: 8px;">
|
||||
🏷️ 标签:<?php single_tag_title(); ?>
|
||||
</h1>
|
||||
<p style="color: var(--text-muted); font-size: 0.9375rem;">
|
||||
共 <?php echo $wp_query->found_posts; ?> 篇文章
|
||||
</p>
|
||||
|
||||
<?php elseif (is_author()) : ?>
|
||||
<h1 style="font-size: 1.75rem; font-weight: 700; margin-bottom: 8px;">
|
||||
👤 作者:<?php the_author(); ?>
|
||||
</h1>
|
||||
<?php if (get_the_author_meta('description')) : ?>
|
||||
<p style="color: var(--text-secondary);"><?php echo get_the_author_meta('description'); ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php elseif (is_year()) : ?>
|
||||
<h1 style="font-size: 1.75rem; font-weight: 700; margin-bottom: 8px;">
|
||||
📅 <?php echo get_the_date('Y'); ?> 年
|
||||
</h1>
|
||||
|
||||
<?php elseif (is_month()) : ?>
|
||||
<h1 style="font-size: 1.75rem; font-weight: 700; margin-bottom: 8px;">
|
||||
📅 <?php echo get_the_date('Y年m月'); ?>
|
||||
</h1>
|
||||
|
||||
<?php elseif (is_day()) : ?>
|
||||
<h1 style="font-size: 1.75rem; font-weight: 700; margin-bottom: 8px;">
|
||||
📅 <?php echo get_the_date('Y年m月d日'); ?>
|
||||
</h1>
|
||||
|
||||
<?php elseif (is_search()) : ?>
|
||||
<h1 style="font-size: 1.75rem; font-weight: 700; margin-bottom: 8px;">
|
||||
🔍 搜索:<?php echo get_search_query(); ?>
|
||||
</h1>
|
||||
<p style="color: var(--text-muted); font-size: 0.9375rem;">
|
||||
找到 <?php echo $wp_query->found_posts; ?> 个结果
|
||||
</p>
|
||||
|
||||
<?php else : ?>
|
||||
<h1 style="font-size: 1.75rem; font-weight: 700; margin-bottom: 8px;">
|
||||
📄 归档
|
||||
</h1>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- Posts Grid -->
|
||||
<div class="posts-grid">
|
||||
<?php if (have_posts()) : ?>
|
||||
<?php while (have_posts()) : the_post(); ?>
|
||||
<article class="post-card" <?php post_class(); ?>>
|
||||
<div class="post-card-header">
|
||||
<?php
|
||||
$categories = get_the_category();
|
||||
if (!empty($categories)) :
|
||||
?>
|
||||
<a href="<?php echo esc_url(get_category_link($categories[0]->term_id)); ?>" class="post-category">
|
||||
<?php echo esc_html($categories[0]->name); ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<span class="post-date">
|
||||
<time datetime="<?php echo get_the_date('c'); ?>">
|
||||
<?php echo get_the_date('Y年m月d日'); ?>
|
||||
</time>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<h2 class="post-card-title">
|
||||
<a href="<?php the_permalink(); ?>">
|
||||
<?php the_title(); ?>
|
||||
</a>
|
||||
</h2>
|
||||
|
||||
<div class="post-excerpt">
|
||||
<?php the_excerpt(); ?>
|
||||
</div>
|
||||
|
||||
<div class="post-card-footer">
|
||||
<div class="post-meta">
|
||||
<span class="post-meta-item">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<circle cx="12" cy="12" r="10"/>
|
||||
<polyline points="12,6 12,12 16,14"/>
|
||||
</svg>
|
||||
<?php echo techblog_reading_time(); ?> 分钟阅读
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<a href="<?php the_permalink(); ?>" class="read-more">
|
||||
阅读全文
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<line x1="5" y1="12" x2="19" y2="12"/>
|
||||
<polyline points="12,5 19,12 12,19"/>
|
||||
</svg>
|
||||
</a>
|
||||
</div>
|
||||
</article>
|
||||
<?php endwhile; ?>
|
||||
|
||||
<!-- Pagination -->
|
||||
<?php
|
||||
the_posts_pagination(array(
|
||||
'mid_size' => 2,
|
||||
'prev_text' => '← 上一页',
|
||||
'next_text' => '下一页 →',
|
||||
));
|
||||
?>
|
||||
|
||||
<?php else : ?>
|
||||
<article class="post-card">
|
||||
<h2 class="post-card-title">暂无文章</h2>
|
||||
<div class="post-excerpt">
|
||||
<p>该分类下暂无文章。</p>
|
||||
</div>
|
||||
</article>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php get_footer(); ?>
|
||||
Reference in New Issue
Block a user