-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate-functions.php
More file actions
29 lines (25 loc) · 978 Bytes
/
Copy pathtemplate-functions.php
File metadata and controls
29 lines (25 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/**
* Show posts pagination.
*/
function maupassant_posts_pagination() {
global $wp_query;
$paged = max(1, get_query_var('paged', 1));
$max = isset($wp_query->max_num_pages) ? (int)$wp_query->max_num_pages : 1;
if ($max <= 1) return;
// 添加分页包装器,用于更好的布局控制
echo '<div class="pagination-wrapper">';
echo '<nav class="maupassant-pagination-breadcrumbs" aria-label="文章导航">';
// 计算下一页的URL
$next_page_url = '';
if ($paged < $max) {
$next_page_url = get_pagenum_link($paged + 1);
}
// 显示分页信息,如果当前页不是最后一页,则"共Y页"可点击
if ($paged < $max && $next_page_url) {
echo '<span class="pagination-info">第 ' . $paged . ' 页,<a href="' . esc_url($next_page_url) . '" class="total-pages-link">共 ' . $max . ' 页</a></span>';
} else {
echo '<span class="pagination-info">第 ' . $paged . ' 页,共 ' . $max . ' 页</span>';
}
echo '</nav>';
echo '</div>';
}