How to Create an Archive Index in WordPress?

125. How to create an Archive Index in WordPress

You need to create it as a Page, and assign it a special template to set up a separate archive index .

You should start off with a simple template called archive.php, stored in your theme’s directory. The WordPress D    efault Theme includes such a template, and it makes a great starting point.

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 to edit your template later.

You should create archive.php in your theme directory (wp-content/themes/themename/). Then from the Admin Panel, Pages > Add new

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

Open the Page templates box in the Sidebar, and select the Archives template. After saving it you will see a new item in your pages list, click on it, and you can enjoy!

Hope you liked this article!

Share this!

Post Author: Staff

Leave a Reply

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