How Can I Create An Archive Index In WordPress?

127. How can I create an Archive Index in WordPress

If  you want a single page with links to all your archived entries, arranged just so to form the main gateway into your blog’s past. You can create template files to customize this archive gateway for every theme you use.

To set up a separate archive index you should create it as a Page, and assign it a special template.

You should start with a simple template called archive.php, stored in your theme’s directory. The WordPress Default Theme includes such a template, and it is a good starting point.

But the default theme for WordPress 3.0 and beyond does not have a built in archives template. Something like this can do the trick (you will need to adapt the html structure to match your current theme):

<?php /* Template Name: Archives */ get_header(); ?> <div id=”container”> <div id=”content” role=”main”> <?php the_post(); ?> <h1 class=”entry-title”><?php the_title(); ?></h1> <?php get_search_form(); ?> <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><!– #content –> </div><!– #container –> <?php get_sidebar(); ?> <?php get_footer(); ?>

Technically, the template may be called almost anything . Anyway, using a standard name for your template will make it easier to change your blog’s theme or distribute your theme and template to the WordPress community. You can also display a large archive index using one of the all-purpose templates and the is_page function, but again, taking advantage of the theme system’s modularity makes it easier for others  to edit your template later.

Create archive.php in your theme directory . Then from the Admin Panel, Pages > Add new

  1. Give your new archives Page a suitable title, something like Site Archives. Leave the Page content blank.

In the sidebar open the Page templates box, and select the Archives template. After saving it you will see a new item in your pages list, click on it, and you’re done!

Hope you liked this article, guys!

Share this!

Post Author: Staff

Leave a Reply

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