-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
33 lines (25 loc) · 840 Bytes
/
Copy pathfunctions.php
File metadata and controls
33 lines (25 loc) · 840 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
30
31
32
33
<?php
/*
Theme Name: Max
Version: 0.1
Author: mec0825
Author URI: http://www.mec0825.net
*/
// Pagenavi of archive and index part
function pagenavi( $p = 5 ) {
if ( is_singular() ) return;
global $wp_query, $paged;
$max_page = $wp_query->max_num_pages;
if ( $max_page == 1 ) return;
echo '<ol class="page-navigator">';
if ( empty( $paged ) ) $paged = 1;
if ( $paged > 1 ) p_link( $paged - 1, 'previous', '« Previous' );
if ( $paged < $max_page ) p_link( $paged + 1,'next', 'Next »' );
echo '</ol>';
}
function p_link( $i, $title = '', $linktype = '' ) {
if ( $title == '' ) $title = "第 {$i} 页";
if ( $linktype == '' ) { $linktext = $i; } else { $linktext = $linktype; }
echo "<div><a href='", esc_html( get_pagenum_link( $i ) ), "' class='{$title}'>{$linktext}</a></div>";
}
?>