Home » Wordpress

WordPress: Create custom archive page

22 December 2009 309 views Popularity: 1% Share/Bookmark

email

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!

Related posts:

  1. WordPress: Archive link not working
  2. WordPress: Optimizing 404 Page Not Found page
  3. How to show child page (sub page) list in parent page in wordpress?
  4. Left or Right Align your image, adsense code or other advertisement in wordpress
  5. WordPress MU: Admin login problem
  6. Twitter, Facebook, WordPress getting together
  7. Magento: Create CMS Page & Static Block programmatically
  8. WordPress Fix: open_basedir restriction in effect. File(/tmp) is not within the allowed path(s)
  9. WordPress Contact Form 7: Quick Fix to spinning arrow displays forever & no success/error message displayed
  10. WordPress Plugin: Quick Adsense 1.0