wp-duckbehaviorjournal/archive-letter.php
Kumi 9ece16c681
feat: improve pagination styling and functionality
Updated pagination implementation in `archive-article.php` and `archive-letter.php` to use global `$wp_query` for accurate page counts and improved navigation. Enhanced user experience by adding more pagination options such as `prev_next`, `show_all`, and customizable text for previous and next links.

Added new styles to `style.css` to center pagination, improve link aesthetics, and highlight the current page.

This enhancement provides a more user-friendly interface and consistent appearance across archive pages.
2024-08-03 12:59:01 +02:00

52 lines
No EOL
1.9 KiB
PHP

<?php get_header(); ?>
<!-- Archive Content -->
<section class="container my-5">
<h1 class="display-4 text-center">Letters to the Editor</h1>
<div class="list-group">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<a href="<?php the_permalink(); ?>" class="list-group-item list-group-item-action">
<h5 class="mb-1"><?php the_title(); ?></h5>
<p class="mb-1">
<?php
$authors = get_post_meta(get_the_ID(), 'article_authors', true);
if (!empty($authors)) {
echo esc_html($authors[0]);
if (count($authors) > 1) {
echo ' et al.';
}
} else {
the_author();
}
?> | <?php the_date(); ?>
</p>
<p class="mb-1"><?php the_excerpt(); ?></p>
</a>
<?php endwhile;
else : ?>
<p><?php _e('Sorry, no letters found.', 'duck-behavior-journal'); ?></p>
<?php endif; ?>
</div>
<div class="row mt-4">
<div class="pagination col-md-12">
<?php
global $wp_query;
echo paginate_links(array(
'total' => $wp_query->max_num_pages,
'current' => max(1, get_query_var('paged')),
'format' => '?paged=%#%',
'show_all' => false,
'end_size' => 2,
'mid_size' => 1,
'prev_next' => true,
'prev_text' => __('« Prev', 'duck-behavior-journal'),
'next_text' => __('Next »', 'duck-behavior-journal'),
'type' => 'plain'
));
?>
</div>
</div>
</section>
<?php get_footer(); ?>