Wordpress: Create custom archive page
Here is the procedure to create a custom archive page for your wordpress blog.
1) Create a file archives.php
2) Write the following code in it.
<?php
/*
Template Name: Archives
*/
?>
<?php get_header(); ?>
<div id="content">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post" id="post_<?php the_ID(); ?>">
<h2 class="title"><?php the_title(); ?></h2>
<div class="entry clearfloat">
<h3>Yearly Archive</h3>
<ul><?php wp_get_archives('type=yearly&show_post_count=1'); ?></ul>
<h3>Monthly Archive</h3>
<ul><?php wp_get_archives('type=monthly&show_post_count=1'); ?></ul>
<h3>Category Archive</h3>
<ul><?php wp_list_cats('sort_column=name&optioncount=1') ?></ul>
<h3>Posts Archive</h3>
<ul><?php wp_get_archives('type=postbypost') ?></ul>
</div>
<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
</div>
<?php endwhile; endif; ?>
</div>
<?php get_sidebar(); ?>
3) Upload it (archives.php) in your current wordpress theme directory.
4) From Wordpress admin panel, create a page name Archives.
5) For this page, set Template to Archives. i.e. Attributes >> Templates = Archives (In WP 2.8, you should find ‘Attributes’ under ‘Update Page’ button).
6) Publish the page and you are done.
Enjoy!


Leave your response!