This covers how to create a basic archives page, using a template. It’s fairly similar to the previous post, apart from the coding.

1. archives.php

In the WP admin panel, go to Presentation » Theme Editor. Open archives.php.

Open archives.php manually on Notepad or something similar, if your files are not writable.

  • If your theme does not have an archives.php file, create a file in Notepad called archives.php. Remember to type .php when you save the file type.
  • There’s a difference between archive.php and archives.php. archives.php (with the s) is usually the template default for an archives page.

2. Configuring archives.php

Add this to the top of the archives.php file.

This enables the php file to be called out as a template.

<?php/*

Template Name: Archives Page

*/

?>

Add the following code below.

You might already have this in your theme’s archives.php file. It displays your archives according to month and subject.

<h2>Archives by Month:</h2><ul>

<?php wp_get_archives(’type=monthly’); ?>

</ul>

<h2>Archives by Subject:</h2>

<ul>

<?php wp_list_categories(); ?>

</ul>

3. The full archives.php

This is an example of a full archives.php file.

<?php
/*

Template Name: Archives Page

*/

?>
<?php get_header(); ?><!– Container –><div class=”CONBG”>
<div class="CON"><!-- Start SC --><div class="SC">
<?php include (TEMPLATEPATH . '/searchform.php'); ?>

<h2>Archives by Month:</h2>

<ul>

<?php wp_get_archives('type=monthly'); ?>

</ul>

<h2>Archives by Subject:</h2>

<ul>

<?php wp_list_categories(); ?>

</ul>

</div>

<!-- End SC -->

<?php get_sidebar(); ?>

<!-- Container -->

</div></div>

<?php get_footer(); ?>

The codes above and below the archives section, follow the main index template, so that the rest of the page’s design is called out.

4. Create “Archives” Page

In WP admin, go to Write » Write Page.

Create a new page titled “archives”. Leave the page content blank.

5. Apply Template to Page

When you’re on Write Page, look to the right.

Apply the Archives Page Template (which is archives.php).

apply archives template

Now you should have a working Archives page.

Related Post