Previously, I wrote an article describing about how to build archive page for WordPress blog without plugin. I was also using exactly that same procedure in this blog for the complete archive page. It works properly, but the problem with that procedure is that it shows all the date based archive posts from the blog in a single page.
Later, I tried to insert the pagination property in the coding section to split the page in sub pages. But could not get any success. Even I did not find any solution for that problem when searching in Google. Atlast, after a year, I’ve succeeded to insert the pagination in the custom archive page template. The procedure is simple and very similar to the previous codes.
All that you have to do is to add some new code with that. Lets proceed..
Follow the previous procedure and find out the following line.
<?php // Declare some helper vars
Now add the following code before that.
<! --start code--> <?php $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=60'.'&paged='.$paged); ?> <! -- end code -->
Note: You can change the number of posts to be shown in a page. Here it is 60.
Again look for the line below:
$myposts = get_posts('numberposts=-1&orderby=post_date &order=DESC');
Replace that by
$myposts = get_posts('orderby=post_date&order=DESC&showposts=60'.'&paged='.$paged);
Again, find out the line where the loop ends i.e look for the line
<?php endforeach; ?> </ul>
Add the following code after that line.
<! --start code--> <div class="pagenavi"> <?php if(function_exists('wp_pagenavi')) : ?> <?php wp_pagenavi() ?> <?php else : ?> <span class="newer"><?php previous_posts_link(__('<< Newer Entries', 'inove')); ?></span> <span class="older"><?php next_posts_link(__('Older Entries >>', 'inove')); ?></span> <?php endif; ?> </div> <?php $wp_query = null; $wp_query = $temp;?> <! -- end code -->
Save the archive template. You should wisely insert appropriate place holder and CSS attributes for the design purpose. You can download the complete code from here.
let me know if you like use the plugin or the above custom template code for your blog archive.