WordPress includes a default archiving tool capable of organizing your posts according to date. You can include the archive tree as a widget in any of the side bar or footer panels on your page. For some WordPress users, however, this is not an acceptable solution. They prefer a custom archive page that lists all of their posts, including titles, in a single place. Fortunately, this is fairly easy to do.
You can create a custom archive page using either a manually created template or one of several plugins. We will discuss both options here. In addition, you might want to consider a custom archive page for SEO purposes. A separate archive page works similar to a site map inasmuch as it gives search engines more information to work with when indexing and categorizing your site.
Creating an Archive Page Manually
Creating an archive page manually is a three-step process that only requires a bit of simple copying and pasting. Start by creating a new text file using your word processor or text editor; copy and paste the following code into that file:
<?php /* Template Name: Template1 */ ?>
This code is only the starting point, so save your file as ‘blog[the name of your template].php’ before going any further. If the name of your template is ‘generic_template’ for example, you would save the newly created file as ‘bloggeneric_template.php. As a side note, we chose ‘Template1’ for your new template name – you can choose anything you like.
The second step is to open the page.php file within your template directory and copy the styling from it. Paste that styling into your newly created template file. The third and final step is to copy and paste the code below into your file before saving and uploading it to your theme directory:
// the query
$wpb_all_query = new WP_Query(array(‘post_type’=>’post’, ‘post_status’=>’publish’, ‘posts_per_page’=>-1)); ?>
<?php if ( $wpb_all_query->have_posts() ) : ?>
<!– the loop –>
<?php while ( $wpb_all_query->have_posts() ) : $wpb_all_query->the_post(); ?>
<li><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></li>
<?php endwhile; ?>
<!– end of the loop –>
<?php wp_reset_postdata(); ?>
<?php else : ?>
<p><?php _e( ‘Sorry, no posts matched your criteria.’ ); ?></p>
<?php endif; ?>
Creating Your Archive Page with a Plugin
If you do not have the technical skill to modify your template, no worries. There are two very good plugins you can use to create your custom archive page. You might want to look at each one first to see which is more to your liking. Once you decide, simply download and install the plugin as you would any other. The two plugins are:
- Display Posts Shortcode – This plugin displays all of your posts in chronological order. It requires no configuration. Just install it, create a new page, and paste the shortcode from the plugin into that page.
- Simple Yearly Archive – This plugin organizes your archives by year. Users can then click on the year and see all of the posts listed chronologically. This plugin does require some configuration in the settings menu, but it’s fairly simple to do.
Now you know how to create a custom archive page for your WordPress site.
Sources for the code: