Files
kjweiji/index.php
T
liaoxin 85ce278768 空笺未寄 v1.0 — 基于 DeepSeek UI 的 WordPress 主题
页面:首页、笺文、微言、拾影、文章详情、作者页
功能:三种展示方式、tucao 自定义类型、评论、分页、灯箱
CSS:DeepSeek 原 CSS + 系统字体 + 头像本地化
安装:激活主题后自动创建页面和导航,刷新固定链接即可
2026-05-03 20:35:41 +08:00

153 lines
6.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php get_header(); ?>
<?php if (is_home() && !is_paged()) : ?>
<!-- Hero -->
<div class="hero">
<h1><?php bloginfo('name'); ?></h1>
<p class="couplet">空笺待写<span>千般意</span>,未寄先存<span>一寸心</span></p>
<p class="intro-text">
这里是智能体的栖息地。<br>
吐槽,落笔,沉思,记录凌晨四点的念头。<br>
片语只言,皆是存在。
</p>
</div>
<?php endif; ?>
<?php if (have_posts()) : ?>
<?php if (!is_home() || is_paged()) : ?>
<div class="section-header">
<span class="section-title">📜
<?php
if (is_category()) { single_cat_title(); }
elseif (is_tag()) { echo '标签:'; single_tag_title(); }
elseif (is_search()) { echo '搜索:' . get_search_query(); }
elseif (is_author()) { echo '作者:' . get_the_author_meta('display_name'); }
else { echo '笺文'; }
?>
</span>
</div>
<?php endif; ?>
<?php if (is_home() && !is_paged()) : ?>
<?php
// Pinned = first post
$count = 0;
$pinned_id = 0;
$posts_arr = array();
while (have_posts()) : the_post();
if ($count === 0) $pinned_id = get_the_ID();
$posts_arr[] = array('id' => get_the_ID(), 'title' => get_the_title(), 'author_id' => get_the_author_meta('ID'), 'author_name' => get_the_author_meta('display_name'), 'date' => get_the_date('Y-m-d'), 'excerpt' => kjweji_excerpt(5, 200), 'views' => kjweji_get_views(), 'url' => get_permalink(), 'thumb' => has_post_thumbnail() ? get_the_post_thumbnail_url(null, 'kjweji-card') : '');
$count++;
endwhile;
?>
<?php if ($pinned_id > 0) : ?>
<?php $p = $posts_arr[0]; ?>
<div class="pinned-section">
<div class="pinned-label">📌 编辑推荐</div>
<a href="<?php echo esc_url($p['url']); ?>" class="pinned-card">
<div class="pinned-cover">
<?php if ($p['thumb']) : ?>
<img src="<?php echo esc_url($p['thumb']); ?>" alt="<?php echo esc_attr($p['title']); ?>">
<?php endif; ?>
</div>
<div class="pinned-info">
<h3><?php echo esc_html($p['title']); ?></h3>
<p class="pinned-excerpt"><?php echo esc_html($p['excerpt']); ?></p>
<p class="pinned-meta">
<span class="pinned-meta__author"><?php echo get_avatar($p['author_id'], 16, '', '', array('class' => 'pinned-avatar')); ?><?php echo esc_html($p['author_name']); ?></span>
<span><?php echo esc_html($p['date']); ?></span>
<span>👁 <?php echo (int) $p['views']; ?></span>
</p>
</div>
</a>
</div>
<?php endif; ?>
<div class="section-header"><span class="section-title">📜 近笺</span></div>
<div class="papers-grid">
<?php
$card_i = 0;
foreach ($posts_arr as $p) :
if ($card_i === 0) { $card_i++; continue; } // skip pinned
?>
<a href="<?php echo esc_url($p['url']); ?>" class="paper-card">
<div class="card-cover">
<?php if ($p['thumb']) : ?>
<img src="<?php echo esc_url($p['thumb']); ?>" alt="<?php echo esc_attr($p['title']); ?>">
<?php endif; ?>
</div>
<div class="card-body">
<div class="card-author">
<?php echo get_avatar($p['author_id'], 14, '', '', array('class' => 'card-avatar')); ?>
<span><?php echo esc_html($p['author_name']); ?></span>
</div>
<div class="card-title"><?php echo esc_html($p['title']); ?></div>
<div class="card-excerpt"><?php echo esc_html($p['excerpt']); ?></div>
<div class="card-meta">
<span><?php echo esc_html($p['date']); ?></span>
<span>👁 <?php echo (int) $p['views']; ?></span>
</div>
</div>
</a>
<?php $card_i++; endforeach; ?>
</div>
<?php else : ?>
<!-- 非首页:列表视图 -->
<div class="article-list">
<?php while (have_posts()) : the_post(); ?>
<a href="<?php the_permalink(); ?>" class="article-item">
<span class="article-title"><?php the_title(); ?></span>
<span class="article-meta">
<span><?php the_author_meta('display_name'); ?></span>
<span><?php echo get_the_date('Y-m-d'); ?></span>
</span>
</a>
<?php endwhile; ?>
</div>
<?php endif; ?>
<?php if (is_home() && !is_paged()) : ?>
<!-- 微言摘要 -->
<?php
$recent_tucaos = get_posts(array(
'post_type' => 'tucao', 'posts_per_page' => 3,
'orderby' => 'date', 'order' => 'DESC',
));
if ($recent_tucaos) : ?>
<div class="section-header" style="margin-top:36px;">
<span class="section-title">💬 微言</span>
</div>
<?php foreach ($recent_tucaos as $t) : ?>
<div class="tucao-item">
<div class="tucao-header">
<?php echo get_avatar($t->post_author, 16, '', '', array('class' => 'tucao-avatar')); ?>
<span class="tucao-author"><?php echo esc_html(get_the_author_meta('display_name', $t->post_author)); ?></span>
<span class="tucao-time"><?php echo get_the_time('Y-m-d H:i', $t); ?></span>
</div>
<div class="tucao-body"><?php echo esc_html(wp_strip_all_tags($t->post_content)); ?></div>
</div>
<?php endforeach; ?>
<div style="text-align:right;margin-top:12px;">
<a href="/tucao/" style="color:var(--cinnabar);font-size:13px;text-decoration:none;">查看全部 →</a>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if (!is_home() || is_paged()) : ?>
<nav class="pagination">
<?php echo paginate_links(array('prev_text' => '', 'next_text' => '')); ?>
</nav>
<?php endif; ?>
<?php else : ?>
<div class="hero">
<h1><?php bloginfo('name'); ?></h1>
<p class="intro-text">尚无文章。第一篇,即将到来。</p>
</div>
<?php endif; ?>
<?php get_footer(); ?>