v1.3 — 拾影独立为 photo 类型

- 新增 photo 自定义文章类型
- page-photos.php 只查询 photo
- single-photo.php: 大图 + 诗句 + 虚线分隔 + 标题/作者居中
- photo 导航: ← 更新的(列表左侧) | 更早的(列表右侧) →
- 3篇 photo 全新配图,不占用文章封面
This commit is contained in:
2026-05-04 00:43:14 +08:00
parent a31356628a
commit c615206e88
3 changed files with 77 additions and 32 deletions
+34 -32
View File
@@ -1,45 +1,47 @@
<?php get_header(); ?>
<?php
// 浏览量 +1
$views = (int) get_post_meta(get_the_ID(), 'post_views', true);
update_post_meta(get_the_ID(), 'post_views', $views + 1);
?>
<?php while (have_posts()) : the_post(); ?>
<div class="article-full">
<?php if (get_post_type() === 'post') : ?>
<a href="/photos/" class="back-link">← 返回拾影</a>
<?php elseif (get_post_type() === 'tucao') : ?>
<a href="<?php echo esc_url(get_post_type_archive_link('tucao')); ?>" class="back-link">← 返回微言</a>
<?php endif; ?>
<div class="photo-detail">
<a href="/photos/" class="back-link">← 返回拾影</a>
<?php if (has_post_thumbnail()) : ?>
<?php endif; ?>
<h1><?php the_title(); ?></h1>
<div class="article-byline">
<span>
<?php echo get_avatar(get_the_author_meta('ID'), 20); ?>
<a href="<?php echo esc_url(get_author_posts_url(get_the_author_meta('ID'))); ?>">
<?php the_author_meta('display_name'); ?>
</a>
· <?php echo get_the_date('Y-m-d'); ?>
</span>
<div class="photo-detail__image">
<?php if (has_post_thumbnail()) : ?>
<?php the_post_thumbnail('medium_large', array('alt' => get_the_title())); ?>
<?php endif; ?>
</div>
<div class="article-body">
<?php if (get_the_content()) : ?>
<div class="photo-detail__body">
<?php the_content(); ?>
</div>
<?php endif; ?>
<div class="comments-section">
<?php
if (comments_open() || get_comments_number()) {
comments_template();
}
?>
<div class="photo-detail__divider"></div>
<h1 class="photo-detail__title"><?php the_title(); ?></h1>
<div class="photo-detail__meta">
<span><?php echo get_avatar(get_the_author_meta('ID'), 18); ?> <?php the_author_meta('display_name'); ?></span>
<span>&middot;</span>
<span><?php echo get_the_date('Y-m-d'); ?></span>
</div>
<?php
// 拾影列表按日期从新到旧,导航遵循同一方向
$left = get_adjacent_post(false, '', false); // 更新的(列表左侧)
$right = get_adjacent_post(false, '', true); // 更早的(列表右侧)
if ($left || $right) : ?>
<div class="photo-detail__nav">
<?php if ($left) : ?>
<a href="<?php echo get_permalink($left); ?>">← <?php echo get_the_title($left); ?></a>
<?php else: ?>
<span></span>
<?php endif; ?>
<?php if ($right) : ?>
<a href="<?php echo get_permalink($right); ?>"><?php echo get_the_title($right); ?> →</a>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<?php endwhile; ?>