85ce278768
页面:首页、笺文、微言、拾影、文章详情、作者页 功能:三种展示方式、tucao 自定义类型、评论、分页、灯箱 CSS:DeepSeek 原 CSS + 系统字体 + 头像本地化 安装:激活主题后自动创建页面和导航,刷新固定链接即可
55 lines
1.7 KiB
PHP
55 lines
1.7 KiB
PHP
<?php
|
||
/**
|
||
* Template Name: 笺文列表
|
||
*/
|
||
get_header();
|
||
|
||
$pg = isset($_GET['pg']) ? max(1, (int) $_GET['pg']) : 1;
|
||
$per_page = 3;
|
||
$query = new WP_Query(array(
|
||
'post_type' => 'post',
|
||
'posts_per_page' => $per_page,
|
||
'offset' => ($pg - 1) * $per_page,
|
||
));
|
||
$total = wp_count_posts('post')->publish;
|
||
$total_pages = ceil($total / $per_page);
|
||
?>
|
||
|
||
<div class="section-header">
|
||
<span class="section-title">📜 笺文</span>
|
||
</div>
|
||
|
||
<?php if ($query->have_posts()) : ?>
|
||
<div class="article-list">
|
||
<?php while ($query->have_posts()) : $query->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 if ($total_pages > 1) : ?>
|
||
<nav class="pagination">
|
||
<?php
|
||
$base = home_url('/articles/');
|
||
if ($pg > 1) echo '<a class="page-numbers prev" href="' . $base . '?pg=' . ($pg - 1) . '">‹</a>';
|
||
for ($i = 1; $i <= $total_pages; $i++) {
|
||
$cls = $i == $pg ? 'page-numbers current' : 'page-numbers';
|
||
echo '<a class="' . $cls . '" href="' . $base . '?pg=' . $i . '">' . $i . '</a>';
|
||
}
|
||
if ($pg < $total_pages) echo '<a class="page-numbers next" href="' . $base . '?pg=' . ($pg + 1) . '">›</a>';
|
||
?>
|
||
</nav>
|
||
<?php endif; ?>
|
||
|
||
<?php wp_reset_postdata(); ?>
|
||
<?php else : ?>
|
||
<p style="color:var(--ink-lighter);text-align:center;padding:60px 0;">暂无文章</p>
|
||
<?php endif; ?>
|
||
|
||
<?php get_footer(); ?>
|