Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ******************** Very Basic Pagination for post ****************
- //Just past this code after post-loop, in where you want to show post pagination
- //You can style this pagination button by using a css class in style.css
- **************** Pagination Code With CSS class **************
- <div class="older_post"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts') ); ?></div>
- <div class="newer_post"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>') ); ?></div>
- **************** Pagination Code only **************
- <?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts') ); ?>
- <?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>') ); ?>
- ***************************************************************************************************
- ******************** Advance Pagination for post ****************
- // Fist paste this bellow code in function.php to ragister pagination function
- 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";
- }
- }
- ****************************************************************
- //than paste this code after post-loop, in where you want to show post pagination
- <?php if (function_exists("pagination")) {
- pagination($additional_loop->max_num_pages);
- } ?>
- **********************************************************************
- //Use this code to style your pagination
- /*for pagination */
- .pagination {
- clear:both;
- padding:20px 0;
- position:relative;
- font-size:11px;
- line-height:13px;
- }
- .pagination span, .pagination a {
- display:block;
- float:left;
- margin: 2px 2px 2px 0;
- padding:6px 9px 5px 9px;
- text-decoration:none;
- width:auto;
- color:#fff;
- background: #555;
- }
- .pagination a:hover{
- color:#fff;
- background: #3279BB;
- }
- .pagination .current{
- padding:6px 9px 5px 9px;
- background: #3279BB;
- color:#fff;
- }
- ********************************************** End of Advance Pagination ******************************************************
- //You can add pagination with using a wordpress plug-in name "WP-PageNavi".This is a very good and awesome plug-in for page navigation.Download link is bellow...............
- Download link : https://wordpress.org/plugins/wp-pagenavi/
- NOTE : To active this plug-in just paste this code where you want to add pagination..............
- <?php wp_pagenavi(); ?>
- //You can style this plug in by useing css class
- ********************************************************** THANKS *****************************************************
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement