Membuat Navigasi di WordPress tanpa Plugin

Membuat vavigasi Di wordpress tanpa plugin ternyata cukup mudah, dengan memanfaatkan fungsi

get_pagenum_link

dan

wp_query

Oke langsung saja ini functions nya.

function danker_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><div>';
if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo '<a href="'.get_pagenum_link(1).'" title="First Page">&laquo;</a>';
if($paged > 1 && $showitems < $pages) echo '<a href="'.get_pagenum_link($paged - 1).'" rel="prev" >&larr; Previous </a>';

for ($i=1; $i <= $pages; $i++){
if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )){
echo ($paged == $i)? "<span class=\"current\">".$i."</span>":"<a href='".get_pagenum_link($i)."' class=\"inactive\">".$i."</a>";
}
}

if ($paged < $pages && $showitems < $pages) echo '<a href="'.get_pagenum_link($paged + 1).' title="next page" rel="next" >Next &rarr;</a>';
if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages) echo '<a href="'.get_pagenum_link($pages).'" rel="next" title="last page">&raquo;</a>';
echo "</div></div>\n";
}
}

 

Paste saja code tersebut di functions.php theme wordpress anda. Kemudian Paste CSS nya di style.css

.pagination {
margin:10px auto;
position:relative;
font-size:11px;
line-height:13px;
width:350px;
}

.pagination span, .pagination a {
display:block;
float:left;
margin: 2px 2px 2px 0;
padding:6px 9px 5px 9px;
text-decoration:none;
width:auto;
color:#555;
background: #fff;

}

.pagination a:hover{
color:#fff;
background: #e54d24;
}

.pagination .current{
padding:6px 9px 5px 9px;
background: #e54d24;
color:#fff;
}

Dan anda bisa pasang codenya di index.php dan atau archive.php dan atau search.php

ini contohnya:
membuat navigasi di wordpress

Download Source : danker_pagination.zip