Creating a Custom Archive Page in WordPress Is Easy

WordPress

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:

<?php

// 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() ) : ?>

<ul>

<!– 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 –>

</ul>

<?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:
http://www.wpbeginner.com/wp-tutorials/how-to-display-all-your-wordpress-posts-on-one-page/
http://www.wpbeginner.com/wp-tutorials/55-most-wanted-wordpress-tips-tricks-and-hacks/

Share it!Share on FacebookTweet about this on TwitterShare on Google+Email this to someone

Our Recommended Wordpress Web Hosting Provider

WordPress

WHC.CA
Get a 50% Discount by using our link.

WHC.ca

Reliable host, with excellent customer service and an easy one-click Wordpress installation. Our recommendation to host a Wordpress blog.

Leave a Reply

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