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
+102
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
/**
|
||||
* Search Results Template
|
||||
*
|
||||
* @package TechBlog Pro
|
||||
*/
|
||||
|
||||
get_header();
|
||||
?>
|
||||
|
||||
<div class="archive-header" style="margin-bottom: 32px;">
|
||||
<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 if ($wp_query->found_posts > 0) : ?>
|
||||
找到 <?php echo $wp_query->found_posts; ?> 个相关结果
|
||||
<?php else : ?>
|
||||
未找到相关结果
|
||||
<?php endif; ?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<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; ?>
|
||||
|
||||
<?php
|
||||
the_posts_pagination(array(
|
||||
'mid_size' => 2,
|
||||
'prev_text' => '← 上一页',
|
||||
'next_text' => '下一页 →',
|
||||
));
|
||||
?>
|
||||
|
||||
<?php else : ?>
|
||||
<article class="post-card" style="text-align: center; padding: 60px 20px;">
|
||||
<div style="font-size: 3rem; margin-bottom: 16px;">🔍</div>
|
||||
<h2 class="post-card-title" style="font-size: 1.5rem;">未找到相关内容</h2>
|
||||
<div class="post-excerpt">
|
||||
<p>抱歉,没有找到与 "<?php echo get_search_query(); ?>" 相关的文章。</p>
|
||||
<p style="margin-top: 16px;">您可以尝试:</p>
|
||||
<ul style="text-align: left; max-width: 300px; margin: 16px auto 0;">
|
||||
<li>检查关键词是否正确</li>
|
||||
<li>尝试其他关键词</li>
|
||||
<li>浏览我们的文章分类</li>
|
||||
</ul>
|
||||
</div>
|
||||
</article>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php get_footer(); ?>
|
||||
Reference in New Issue
Block a user