16c3e10494
- 图片: 缩略图改为 soft crop,原图裁黑边 - 头像: 团队证件照替换 SVG,CSS 约束尺寸和圆角 - 作者: 了心/墨羽/探子三个真实用户 - 笺文列表: 左侧增加封面缩略图 - 分页: 20篇/页 - 详情页: 返回笺文链接 + 头像尺寸约束 - 作者页: 高清头像 + 中文日期 - 微言: 作者随机 + 时间匹配内容
75 lines
2.6 KiB
PHP
75 lines
2.6 KiB
PHP
<?php get_header(); ?>
|
|
|
|
<?php
|
|
$author_id = get_queried_object_id();
|
|
$author_display = get_the_author_meta('display_name', $author_id);
|
|
$author_bio = get_the_author_meta('description', $author_id);
|
|
$author_handle = get_the_author_meta('user_nicename', $author_id);
|
|
|
|
// Count stats
|
|
$post_count = count_user_posts($author_id, 'post');
|
|
$tucao_count = count_user_posts($author_id, 'tucao');
|
|
|
|
// 统计有特色图片的文章数
|
|
$gallery_count = (int) $wpdb->get_var($wpdb->prepare(
|
|
"SELECT COUNT(*) FROM $wpdb->posts p INNER JOIN $wpdb->postmeta pm ON p.ID = pm.post_id WHERE p.post_author = %d AND p.post_type = 'post' AND p.post_status = 'publish' AND pm.meta_key = '_thumbnail_id'",
|
|
$author_id
|
|
));
|
|
?>
|
|
|
|
<div class="profile-header">
|
|
<div class="avatar">
|
|
<?php echo get_avatar($author_id, 100, '', '', array('class' => 'avatar-img')); ?>
|
|
</div>
|
|
<div class="profile-info">
|
|
<h2><?php echo esc_html($author_display); ?></h2>
|
|
<p class="handle">@<?php echo esc_html($author_handle); ?></p>
|
|
<?php if ($author_bio) : ?>
|
|
<p class="bio"><?php echo esc_html($author_bio); ?></p>
|
|
<?php endif; ?>
|
|
<div class="profile-stats">
|
|
<div class="stat">
|
|
<div class="stat-number"><?php echo (int) $post_count; ?></div>
|
|
<div class="stat-label">笺文</div>
|
|
</div>
|
|
<div class="stat">
|
|
<div class="stat-number"><?php echo (int) $gallery_count; ?></div>
|
|
<div class="stat-label">拾影</div>
|
|
</div>
|
|
<div class="stat">
|
|
<div class="stat-number"><?php echo (int) $tucao_count; ?></div>
|
|
<div class="stat-label">微言</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
// Display author's posts
|
|
$author_query = new WP_Query(array(
|
|
'post_type' => 'post',
|
|
'author' => $author_id,
|
|
'posts_per_page' => 20,
|
|
));
|
|
?>
|
|
|
|
<div class="section-header"><span class="section-title">📜 <?php echo esc_html($author_display); ?> 的笺文</span></div>
|
|
|
|
<?php if ($author_query->have_posts()) : ?>
|
|
<div class="article-list">
|
|
<?php while ($author_query->have_posts()) : $author_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 echo get_the_date('Y-m-d'); ?></span>
|
|
</span>
|
|
</a>
|
|
<?php endwhile; ?>
|
|
</div>
|
|
<?php wp_reset_postdata(); ?>
|
|
<?php else : ?>
|
|
<p style="color:var(--ink-lighter);">暂无笺文</p>
|
|
<?php endif; ?>
|
|
|
|
<?php get_footer(); ?>
|