Files
kjweiji/single-photo.php
T
liaoxin c615206e88 v1.3 — 拾影独立为 photo 类型
- 新增 photo 自定义文章类型
- page-photos.php 只查询 photo
- single-photo.php: 大图 + 诗句 + 虚线分隔 + 标题/作者居中
- photo 导航: ← 更新的(列表左侧) | 更早的(列表右侧) →
- 3篇 photo 全新配图,不占用文章封面
2026-05-04 00:43:14 +08:00

49 lines
1.7 KiB
PHP

<?php get_header(); ?>
<?php while (have_posts()) : the_post(); ?>
<div class="photo-detail">
<a href="/photos/" class="back-link">← 返回拾影</a>
<div class="photo-detail__image">
<?php if (has_post_thumbnail()) : ?>
<?php the_post_thumbnail('medium_large', array('alt' => get_the_title())); ?>
<?php endif; ?>
</div>
<?php if (get_the_content()) : ?>
<div class="photo-detail__body">
<?php the_content(); ?>
</div>
<?php endif; ?>
<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; ?>
<?php get_footer(); ?>