Files
wordpress-theme-aksrt/templates/pages/page-newposts.php
T
kate522 8849540fda 专用页对齐 content-shell,并删 page-header query-var 回退
archives/friends/newposts/posts-navs/categories 统一壳层与 page-header 契约,
主路径不再保留 aksrt_ph_* ambient 传参。
2026-07-09 23:05:06 +08:00

73 lines
2.2 KiB
PHP

<?php
/**
* Template Name: AKSRT - New Posts
* Template Post Type: page
*
* 最新文章页:按时间倒序展示最新发布的文章。
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
get_header();
$paged = max(1, (int) get_query_var('paged'));
$per_page = 20;
$query = new WP_Query([
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => $per_page,
'paged' => $paged,
'orderby' => 'date',
'order' => 'DESC',
]);
if (function_exists('aksrt_archive_open_shell')) {
aksrt_archive_open_shell([
'main_class' => 'site-main container content-shell content-shell--page page-content-default',
'has_sidebar' => false,
'page_kind' => 'newposts',
]);
}
?>
<div class="content-main content-main--page content-main--newposts">
<?php
get_template_part('templates/parts/page-header', null, [
'title' => esc_html(get_the_title() ?: __('最新文章', 'aksrt')),
]);
?>
<div class="aksrt-newposts">
<?php if ($query->have_posts()) : ?>
<div class="aksrt-newposts__list">
<?php while ($query->have_posts()) : $query->the_post(); ?>
<article class="aksrt-newposts__item">
<span class="aksrt-newposts__date"><?php echo esc_html(get_the_date()); ?></span>
<h3 class="aksrt-newposts__title">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</h3>
<p class="aksrt-newposts__excerpt"><?php echo esc_html(wp_trim_words(get_the_excerpt(), 30)); ?></p>
</article>
<?php endwhile; ?>
</div>
<?php
if (function_exists('aksrt_render_pagination')) {
aksrt_render_pagination($query);
} else {
echo '<div class="aksrt-pagination">' . paginate_links(['total' => $query->max_num_pages]) . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
wp_reset_postdata();
?>
<?php else : ?>
<p class="aksrt-newposts__empty content-stream__empty"><?php esc_html_e('暂无文章。', 'aksrt'); ?></p>
<?php endif; ?>
</div>
</div>
<?php
if (function_exists('aksrt_archive_close_shell')) {
aksrt_archive_close_shell(['has_sidebar' => false]);
}
get_footer();