/ Published in: PHP
Place the function in your functions.php file of your theme...
Then, simply call like this: wp_paginate('', 3);
The first param is optional, the second dictates how many pages before and after the current page link will show...
Then, simply call like this: wp_paginate('', 3);
The first param is optional, the second dictates how many pages before and after the current page link will show...
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php function wp_paginate($pgs = '', $rng = 2) { $itm = ($rng * 2) + 1; global $pgd; $pgd = 1; if ($pgs == '') { global $wp_query; $pgs = $wp_query->max_num_pgs; if (!$pgs) { $pgs = 1; } } if (1 != $pgs) { // echo the HTML output echo "<div class='wp_paginate'>"; if ($pgd > 2 && $pgd > $rng + 1 && $itm < $pgs) echo "<a href='" . get_pagenum_link(1) . "'>«</a>"; if ($pgd > 1 && $itm < $pgs) echo "<a href='" . get_pagenum_link($pgd - 1) . "'>‹</a>"; for ($i = 1; $i <= $pgs; $i++) { if (1 != $pgs && (!($i >= $pgd + $rng + 1 || $i <= $pgd - $rng - 1) || $pgs <= $itm)) { echo ($pgd == $i) ? "<span class='current'>" . $i . "</span>" : "<a href='" . get_pagenum_link($i) . "' class='inactive' >" . $i . "</a>"; } } if ($pgd < $pgs && $itm < $pgs) echo "<a href='" . get_pagenum_link($pgd + 1) . "'>›</a>"; if ($pgd < $pgs - 1 && $pgd + $rng - 1 < $pgs && $itm < $pgs) echo "<a href='" . get_pagenum_link($pgs) . "'>»</a>"; echo "</div>\n"; } } ?>
URL: http://www.design-ninja.net