How to Add Pagination to TwentyTwelve Theme of Your WordPress Blog without a Plugin?


In order to run a WordPress site one need to have hosting and domain. Then, there are multiple ways a WordPress site can be installed. It can be done with various software which most of the times pre-installed with hosting. How to build a good self-hosted WordPress site?

  • The better and easier way to install WordPress site is to use site software. You can learn about this from here.
  • Then you can set up free CloudFlare CDN (content delivery network) for your WordPress Blog. You can learn this from here.
  • Then you can install a free TLS/SSL certificate signed by CloudFlare on your origin server. You can learn this from here.
  • In order to make your blog a full-fledged WordPress site, you can create a landing page without code or plugins. You can learn this from here.
  • There are various ways in which WordPress website can be optimised and speed up in order to reduce latency time. You can learn this from here.
  • There are some shortcut ways through the installation of WordPress plugins you can acquire the additional level of leverages for your site. You can learn this from here.
  • There are some additional ways to increase caching of WordPress site through the installation of Varnish and CloudFlare combination together. You can learn from this here.
  • Last not the least is to create a Child Theme from an unmodified Parent Theme. In this way, any modification done to theme stays after each update to the parent theme. You can learn this development of WordPress idea from here.

What is Pagination in WordPress?

In its built-in functionality of WordPress, we find there are various ways to navigate previous posts. Normally in ‘Twentytwelve’ theme, we do find that there is already a link to previous posts and next posts. Generally, Pagination in WordPress is all about showing numbers and links to previous posts.
First, you need to make how many posts to be viewed on the single blog page. For this:

  • log in to WordPress Admin.
  • Go to wp-admin > Settings > Reading > Blog pages show at most.
  • Then put the number to show how many posts to be shown in front page blog.

Troubleshooting in the showing of Pagination:

It is important to make back up of your template files and then create a child theme before editing them so that your website should not break. How to create pagination we will talk about it later. Now, first the safeguards to make pagination works.

  • Deactivate all plugins which you might feel that is affecting the performance of paginations.
  • If you find this is the answer then slowly activate plugins one by one and then check it and if that problem is not there then reactivate plugins which are not affecting the performance of pagination.
  • If this not works then reset permalinks structure of pages to the default state. For this go to wp-admin > Settings > Permalinks and then set it to the default state.

Then, check the pagination is working or not, and if this works then these cans solve pagination structure problem.

  • If all of these does not work correctly, then you can locate the template file.
  • Then find the main paginated loop so that any chance of multiple posts pagination does not there.
  • Sometimes, with some themes, there is the presence of inbuilt plugins which might work for pagination and when you install the following code that might not work due to the presence of multiple paginations.
  • Then Search for such pagination loops and remove those query posts from the main loop.

How to Add Pagination to TwentyTwelve Theme of Your WordPress Blog without a Plugin:

Twentytwelve Theme is one of most popular theme and it is free. It provides most WordPress developers, brilliant ways to edit and create absolute performance theme, that can be suitable to work for you.

  • Open cPanel. Go to FILES then FILE MANAGER then WP-CONTENT then THEMES.
  • Then go to theme namely twentytwelve-child.
  • Then go to functions.php and go to edit mode of the functions.php file.
  • At the end of the functions.php file of twentytwelve-child paste the following code.
  • This code I take it from this website.
  • http[colon][double slash]adambalee[dot]com[slash]how-to-add-pagination-to-your-wordpress-blog-without-a-plugin[slash]
if ( ! function_exists( 'twentytwelve_content_nav' ) ) :
 function twentytwelve_content_nav() {
 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
 ) );
 }
endif;

Conclusion:

    • This code is exactly what your twentytwelve theme needs.
    • Be sure to back up template file before editing and also create the child theme of it and edit it.
    • Do not edit parent theme of twentytwelve theme. WordPress pagination makes the front page of your website to show links to all of these articles that are inside the blog.
    • This make numbered or numeric pagination also good for SEO (search engine optimisation) of your website.

Related Posts:


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.