68 lines
1.8 KiB
PHP
68 lines
1.8 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',
|
|
]);
|
|
?>
|
|
|
|
<main id="main-content" class="container page-content-default" tabindex="-1">
|
|
<header class="page-header">
|
|
<h1 class="entry-title"><?php echo esc_html(get_the_title() ?: __('最新文章', 'aksrt')); ?></h1>
|
|
</header>
|
|
|
|
<div class="content-wrap">
|
|
<div class="content-layout content-layout--no-sidebar">
|
|
<div class="content-layout__primary">
|
|
<div class="aksrt-newposts container">
|
|
<?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>';
|
|
}
|
|
?>
|
|
<?php wp_reset_postdata(); ?>
|
|
<?php else : ?>
|
|
<p class="aksrt-newposts__empty"><?php esc_html_e('暂无文章。', 'aksrt'); ?></p>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<?php
|
|
get_footer();
|