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:
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
/**
|
||||
* Main Template File
|
||||
*
|
||||
* @package TechBlog Pro
|
||||
*/
|
||||
|
||||
get_header();
|
||||
?>
|
||||
|
||||
<!-- Hero Section -->
|
||||
<?php if (is_front_page()) : ?>
|
||||
<section class="hero-section">
|
||||
<h1 class="hero-title"><?php echo esc_html(get_theme_mod('hero_title', '探索技术世界')); ?></h1>
|
||||
<p class="hero-description"><?php echo esc_html(get_theme_mod('hero_description', '分享最新的IT技术、编程教程、系统运维经验')); ?></p>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- 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>
|
||||
<span class="post-meta-item">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/>
|
||||
<circle cx="12" cy="12" r="3"/>
|
||||
</svg>
|
||||
<?php echo techblog_format_views(techblog_get_post_views()); ?> 阅读
|
||||
</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