Home » Wordpress

Wordpress: Create custom archive page

22 December 2009 119 views No Comment Popularity: 2% Share/Bookmark

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&amp;show_post_count=1'); ?></ul>
			<h3>Monthly Archive</h3>
			<ul><?php wp_get_archives('type=monthly&amp;show_post_count=1'); ?></ul>
			<h3>Category Archive</h3>
			<ul><?php wp_list_cats('sort_column=name&amp;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!

From Mukesh Chapagain's Blog | Post Wordpress: Create custom archive page

Related posts:

  1. Wordpress: Optimizing 404 Page Not Found page
  2. How to show child page (sub page) list in parent page in wordpress?
  3. New Wordpress Plugin – Author Introduction
  4. Wordpress MU: Admin login problem
  5. Left or Right Align your image, adsense code or other advertisement in wordpress

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.