WordPress Pagination With Numbers
WordPress pagination is a built in option in most of the premium themes.If your theme doesn't have this option,no need to worry about that.You can add numeric wordpress pagination without a plugin.WP-PageNavi is a popular WordPress plugin,which adds numbers pagination to posts.But when you consider Speed of your website,it's better to avoid plugins.
How to Add numeric pagination to your WordPress theme
To add numeric pagination to your wordpress theme,add the following code to your themes functions.php
// WordPress Pagination
function myg_pagination() {
global $wp_query;
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages
) );
}
After adding this code add the following code to your index.php, archive.php, category.php,where you want to the pagination to appear.
<?php myg_pagination(); ?>
Finally to style wordpress pagination,add the following code to your css file.
/* Pagination */
.page_nav .page-numbers{
background:#BCBCBC;
color:#fff;
display:block;
width:auto;
float:left;
margin: 4px 4px 4px 0;
padding:15px 18px 14px 18px;
text-decoration:none;
}
.page_nav .page-numbers:hover{
background: #24221D;
color:#fff;
text-decoration: none;
}
.page_nav .current{
background: #24221D;
color:#fff;
padding:15px 18px 14px 18px;
}
You can style the above code as per your current WordPress theme color.In the above code padding,background,color and hover are the main styles.