Add “All Posts” Archive Page to WordPress Blog

For a while now, I’ve been looking for a way to list all my [tag]posts[/tag] on one page, since I don’t see the point of monthly archives and I think it would be neat to have a quick reference to all previous posts. I have been unsuccessful in my search attempts until last night, when I stumbled onto the solution accidentally.

I finally found the [tag]code[/tag] on [tag]WPRecipes[/tag]. However, the code on the site is unformatted, so I’ll jazz it up a little bit so that it will fit your [tag]WordPress[/tag] [tag]theme[/tag].

To do this, you’ll want to create a [tag]page template[/tag] called “All Posts”. Open up notepad (or some text editor) and paste the following.

<?php get_header(); ?>

<div id="contentcontainer">

<div id="left">

$debut = 0;
<?php while(have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2>
$myposts = get_posts('numberposts=-1&offset=$debut');
foreach($myposts as $post) :
<li><?php the_time('d/m/y') ?>: <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
<?php endwhile; ?>


<?php get_sidebar(); ?>


<?php get_footer(); ?>

Save this as “allposts.php” (or something similar) and upload it to the “wp-content/themes/your_theme/” folder. Create a new page in WordPress and select “All Posts” as a page template from the “Attributes” menu on your right.

Publish and you’re in business!

Enjoy the post? Encourage me by subscribing to the feed, following me on Twitter, and becoming a fan on Facebook. Cheers!