-
Notifications
You must be signed in to change notification settings - Fork 0
/
navigation.php
32 lines (32 loc) · 895 Bytes
/
navigation.php
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
<?php if (!is_page()): if(!is_single()) :?>
<div id="navigation">
<?php previous_posts_link('<') ?>
<?php $max = $wp_query->max_num_pages;
$current = $paged; if(!$current) {$current = 1;} ?>
<?php $side = 3; $show = $side * 2 + 1;
if ($current > $side && $current < $max - $side+1) {
$start = $current - $side;
$end = $current + $side;
} elseif($current <= $side) {
$start = 1;
$end = min($show,$max);
} else {
$start = max($max - $show + 1, 1);
$end = $max;
} ?>
<?php for($i=$start; $i <= $end; $i++) : ?>
<?php if ($i == $current ) :?>
<span><?php echo $i ?></span>
<?php else: ?>
<a href="<?php echo get_pagenum_link($i); ?>"><?php echo $i ?></a>
<?php endif; ?>
<?php endfor; ?>
<?php next_posts_link('>') ?>
</div>
<?php else: ?>
<div id="navigation">
<?php previous_post_link( '%link','< %title' ); ?>
<?php next_post_link( '%link','%title >' ); ?>
</div>
<?php endif; ?>
<?php endif; ?>