Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // another pagination
- // show this code where need to show pagination
- <?php pagination(); ?>
- ***************************************************************************
- // call this functions.php
- function pagination($pages = '', $range = 4)
- {
- $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=\"pagination\"><span>Page ".$paged." of ".$pages."</span>";
- if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>« First</a>";
- if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>‹ 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)."\">Next ›</a>";
- if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>Last »</a>";
- echo "</div>\n";
- }
- }
- *********************************************************************************************************************
- // this is style sheet that i have stylized
- .pagination{width:100%;}
- .pagination a{-moz-border-bottom-colors: none;
- -moz-border-left-colors: none;
- -moz-border-right-colors: none;
- -moz-border-top-colors: none;
- background: #f7f7f7 linear-gradient(to bottom, #fff, #eee) repeat scroll 0 0 border-box;
- border-color: rgba(0, 0, 0, 0.2) rgba(0, 0, 0, 0.2) rgba(0, 0, 0, 0.3);
- border-image: none;
- border-style: solid;
- border-width: 1px;
- color: #666;
- margin-right: 5px;
- padding: 5px 10px;
- text-shadow: 0 1px 0 #fff;}
- .pagination a:hover{-moz-border-bottom-colors: none;
- -moz-border-left-colors: none;
- -moz-border-right-colors: none;
- -moz-border-top-colors: none;
- background: #009dd8 linear-gradient(to bottom, #00b4f5, #008dc5) repeat scroll 0 0 border-box;
- border-color: rgba(0, 0, 0, 0.2) rgba(0, 0, 0, 0.2) rgba(0, 0, 0, 0.4);
- border-image: none;
- border-style: solid;
- border-width: 1px;
- color: #fff;
- text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.2);}
- .pagination a.inactive{}
- .pagination span{-moz-border-bottom-colors: none;
- -moz-border-left-colors: none;
- -moz-border-right-colors: none;
- -moz-border-top-colors: none;
- background: #009dd8 linear-gradient(to bottom, #00b4f5, #008dc5) repeat scroll 0 0 border-box;
- border-color: rgba(0, 0, 0, 0.2) rgba(0, 0, 0, 0.2) rgba(0, 0, 0, 0.4);
- border-image: none;
- border-style: solid;
- border-width: 1px;
- color: #fff;
- margin-right:5px;
- padding: 5px 11px;
- text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.2);}
- .pagination span.current{-moz-border-bottom-colors: none;
- -moz-border-left-colors: none;
- -moz-border-right-colors: none;
- -moz-border-top-colors: none;
- background: #009dd8 linear-gradient(to bottom, #00b4f5, #008dc5) repeat scroll 0 0 border-box;
- border-color: rgba(0, 0, 0, 0.2) rgba(0, 0, 0, 0.2) rgba(0, 0, 0, 0.4);
- border-image: none;
- border-style: solid;
- border-width: 1px;
- color: #fff;
- padding: 5px 11px;
- text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.2);}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement