A little help with numbered pagination?
-
I’m using a numbered pagination in my wordpress. The code and the result is pasted below
function kriesi_pagination($pages = '', $range = 2) { $showitems = ($range * 2)+1; global $paged; if(empty($paged)) $paged = 1; if($pages == '') { global $wp_query; $pages = $wp_query->max_num_pages; if(!$pages) { $pages = 1; } } if(1 != $pages) { echo "<div class='navigation'>"; if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>?</a>"; if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>?</a>"; for ($i=1; $i <= $pages; $i++) { if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )) { echo ($paged == $i)? "<a class='pagination-link selected' href='".get_pagenum_link($paged)."'>".$i."</a>":"<a href='".get_pagenum_link($i)."' class='inactive' >".$i."</a>"; } } if ($paged < $pages && $showitems < $pages) echo "<a class='pagination-link' href='".get_pagenum_link($paged + 1)."'>?</a>"; if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>?</a>"; echo "</div>\n"; } }
The result:
<div class='navigation'> <a class='pagination-link selected' href='https://localhost/'>1</a> <a href='https://localhost/?paged=2' class='inactive' >2</a> <a href='https://localhost/?paged=3' class='inactive' >3</a> <a href='https://localhost/?paged=4' class='inactive' >4</a> </div>
Is it possible to remove the
https://localhost/
from pagination links to get result like this<a href='/?paged=2'>2</a>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘A little help with numbered pagination?’ is closed to new replies.