Last active
September 26, 2017 23:22
-
-
Save bulentsakarya/6488f861a5e337031f547f44e6458b47 to your computer and use it in GitHub Desktop.
bootstrap 3.x based wordpress pagination
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function nivo_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 "<nav><ul class=\"pagination\"><li><span>Sayfa ".$paged." / ".$pages."</span></li>"; | |
| if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<li><a href='".get_pagenum_link(1)."'>«</a></li>"; | |
| if($paged > 1 && $showitems < $pages) echo "<li><a href='".get_pagenum_link($paged - 1)."'>‹</a></li>"; | |
| for ($i=1; $i <= $pages; $i++) { | |
| if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )) { | |
| $next_link = ''; | |
| if($paged + 1 == $i) | |
| $next_link = 'next_link'; | |
| echo ($paged == $i)? '<li class="active"><a href="#">'.$i.'</a></li>':"<li><a href='".get_pagenum_link($i)."' class=\"disabled ".$next_link." \">".$i."</a></li>"; | |
| } | |
| } | |
| if ($paged < $pages && $showitems < $pages) echo "<li><a href=\"".get_pagenum_link($paged + 1)."\">›</a></li>"; | |
| if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<li><a href='".get_pagenum_link($pages)."'>»</a></li>"; | |
| echo "</ul></nav>\n"; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment