Genesis Themes

  • Home
  • Genesis Tutorials
  • WP Tutorial
  • Twenty Fifteen Theme
  • Social Media
  • WP Plugins

How to Add WordPress Pagination Without a Plugin

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.

Related Posts

  • How to Add Expires Headers in WordPress
  • Remove Query String from Static Resources in WordPress
  • Disable Disqus Comments on Certain Pages in WordPress
  • How to Add Related Posts with Thumbnails in WordPress
  • Top 10 Most Popular Google Adsense Alternatives 2016
  • How to Create Custom WordPress Sitemap Without Plugin
  • Recommended WordPress Ping List 2017
  • How to Enable Gzip Compression in WordPress
  • Manually Display Disqus Comment Count in WordPress
  • Remove WordPress Emoji Script and Style

Bluehost and Siteground Coupons for January 2016.

Best Premium WordPress Themes from TemplateMonster
download wordpress themes from MonsterOne

Categories

  • Blog
  • Blogger
  • Genesis Tutorials
  • Social Media
  • Top Websites
  • Twenty Fifteen WordPress Theme
  • WordPress Plugins
  • WordPress Tutorial