StylizedWeb is a web design trends and tutorials blog, maintained by Ross Johnson who also runs a web design company and design blog.

Categories Archive

Popular Posts
Advertisement
Basecamp The Web Design Sketchbook
Najbolje ponuda IT poslova u Srbiji na itposlovi.info Advertise on Stylized Web

Wordpress Archive page

add to Save to Delicious Save to Stumble Save to Digg

Since lot of people asked me how i have made my archives page http://stylizedweb.com/archive/ i realized that they are not really familiar with page templates so i looked over the web for some tutorials and i really couldn't find good ones, so this tutorial will shortly explain how to do it.

If your Wordpress blog is getting bigger archive page is really good to have, and here you can list all your posts, months, weeks what ever you want. If you are using some free template look in the theme folder because you could already have it, if you don't here's how to make it.

1. Open your index.php page and save it as archive.php
2. Replace the original loop code with some of these examples (it starts with <?php while(have_posts()) : the_post(); ?> and ends with <?php endwhile; ?> so everything between that)

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

This will list all posts like on http://stylizedweb.com/archive/ you can change offset (number to start from) etc, more on Wordpress codex about it http://codex.wordpress.org/Template_Tags/get_posts. This second code will list categories and month archives.

 
<?php while(have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<ul><?php wp_list_cats(’sort_column=name&optioncount=1) ?></ul>
<ul><?php wp_get_archives(’type=monthly&show_post_count=1) ?></ul>
 
<?php endwhile; ?>
 

3. Add this code at the top of your archive.php page

 
<?php
/*
Template Name: Archives Page
*/
?>
 

4. Upload archive.php to your theme folder
5. Create a new page and Archives Page from the page templates

Page template

Of course if you don't like saving index file as archive you can start from the making a new page and adding all these things.

Leave a comment on Stylized Web Have some feedback? Leave a comment



Talk of the town
  • South West Balloon Flights: Thanks for the script. Looks nice.
  • Tony: How about WP Super Cache. Google now takes into account a site’s loading time and what better way to...
  • Emek Elektrik: Thanks Adminstrator For Dar Gelirli Users…
  • Nelly: That is a good article for css thank you admin
  • Nelly: I want to learn css Can anyone help me? Thanks a lot
Amigos

What do you think?





30 Responses so far

By milind
on November 28, 2009

hi friend thank for these information sharing that before I am very confuse regarding archive template
But one question is remaining as show output on following link
http://stylizedweb.com/archive/
as a same effect possible in the presence of index.php mean as normal template (as regular template)

pls reply as soon as possible

By Tom
on July 23, 2009

Step 2 has some errors. Be sure to remove the space from between the ? php.

By Barbra Hyde
on April 30, 2009

iiocqaeuuw386liw

资料网

By DOTA资料网
on March 22, 2009

最专业的DOTA资料网,提供最全面最新的地图下载,英雄模拟器,录像,战报,攻略。!

By 征途资料站
on March 19, 2009

顶~~~~我叫征途资料站,希望能交个朋友哈!

By DNF资料站
on March 19, 2009
By Mike
on March 2, 2009

Thanks, just what i was looking for too =) thanks

By Shay Howe
on February 28, 2009

Sorry, my code elements were stripped. Hopefully this works.

<a href="">

By Shay Howe
on February 28, 2009

@Markus Török

Try using this with in your list item:

<a href=”">

By 丁香女性网
on February 22, 2009

丁香女性网提供服装搭配、身材与搭配、明星搭配、街头潮流、省钱搭配、色彩搭配、饰品搭配、鞋帽包、搭配图库等最新资讯..

By Markus Török
on December 24, 2008

The first code won’t work for me.
I always get following error message:

Parse error: syntax error, unexpected T_STRING

could anybody help me?

By Diggo
on October 29, 2008

Thanks a lot, dude :)

By Dejan
on April 14, 2008

try this before foreach
<?php $myposts= array_reverse($myposts, true); ?>

By James
on April 14, 2008

Sorry, I meant how did you order it with the latest posts at the top. When I try to use the argument from the get post page on Wordpress it doesn’t work. Thanks.

By Dejan
on April 14, 2008

James
What do you mean ordered list? This is ul with simple text for dates, please explain

By James
on April 14, 2008

Hey

Can you tell me how your ordered your list? I’ve tried using the order argument for ordering the dates similar to yours but nothing seemed to work. Thanks for the help, but this little bit is driving me nuts.

By Yan
on March 29, 2008

Thanks for the tutorial. Just wanna know how could I create archive of pages instead of posts?

By Jermayn Parker
on March 12, 2008

Yeah agree that this type of tut is fairly minimal on the web!
I had to find a theme and copy it for how to do it.

By Stan
on March 9, 2008

very useful, your archive page looks good, thanks

By Marko
on March 8, 2008

good tutorial, thanks!

By Sarah
on March 8, 2008

Awesome! Just what i was looking for, thanks!

  1. Jun 13, 2009: Article Archive Page Added. Add your own archive page easily! (code included) « MartinOgg.com
  2. Apr 18, 2009: Wordpress Trick - HTTP://BLOG.OHLOG.NET
  3. Aug 8, 2008: Engwar » Blog Archive » Minimalism
  4. Jun 27, 2008: ArtsLab
  5. Jun 14, 2008: Useful WordPress Tricks | StylizedWeb.com
  6. Jun 12, 2008: Digg Top OffBeat News of all times » Wordpress Archive page
  7. Jun 12, 2008: Peter Gamez » Wordpress Archive page
  8. Mar 29, 2008: Web 2.0 & Usability Blog by Adam Moss » Blog Archive » 10 Blog Usability Guidelines
  9. Mar 8, 2008: WP Archive page