Creating Helpful and Effective WordPress Archives
87One of the most important elements of your blog, is the content that you painstakingly put together to gain readers and keep the online masses surfing your waves. So why do so many bloggers not take the extra time and give more attention to their archives?
Afterall, without an easy to navigate archive section, then all of that great content that you crafted will become lost in the backpages of your post progression as you continue to crank out the content. It seems that once a post has served its initial use for us, that we carelessly discard it to the forgotten areas for the post to die, rather than institute an accessible archive that will allow those past posts to continue to deliver the punch you packed within.
Our archives allow for an overall easier experience for our readers, by giving them simple access to the content they are looking for. Or more to the point, the information that they do not know they are looking for.
What I mean by that, is this. On occasion, we have users come to our site without a specific target in mind, they are simply browsing for interesting reads. By setting up a thorough collection of your posts, those browsers will have a much easier time surfing for a destination among your archives, keeping the reader engaged and skimming through the content that could have easily fallen through the cracks.
So in this post, I am going to offer some pointers on creating a quality archive section for your blog that will serve as an inspired homage to the awesome content that it contains.
Creating a Template
The first thing you will need to do is to create a WordPress Page Template for your archives page. Here well be creating archives.php in our wordpress theme folder.
So heres the code we are going to start with, then I am going to give you some options to actually customize the page the way you want it.
NOTE: Since the Template Name is Archives, the page must be named archives.php.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <?php /* Template Name: Archives */ ?> <?php get_header(); ?> <div id="archives"> This is where we will actually be building the archives page. </div> <?php get_sidebar(); ?> <?php get_footer(); ?> |
Posts by Date
While listing archives by date isnt usually that helpful for finding a particular post or topic, it is a good way to establish your blog (remember that longevity = reader confidence). I recommend simply listing these archives by month to conserve space.
The following code will list the archives by month with no limit to the number of months it will display.
1 | <?php wp_get_archives(); ?> |
The following code lists the archives by month displaying only the past 12 months.
1 | <?php wp_get_archives('type=monthly&limit=12'); ?> |
You can set the type and limit to whatever your preference is. You can find more information about your options for parameter settings at the WordPress Codex Get Archives Page.
Posts by Category
This will be the most important section of your archives since most readers are not looking for a particular date but for a specific topic.
If you just want to generate a list of your categories use the following code.
1 | <?php wp_list_categories(); ?> |
If you would like to exclude certain categories (for example, blog updates) use this code. In this example, categories 10 and 12 will be excluded. To find the id for the category you want to exclude, go to your admin area and go to Posts > Categories. Right click on the category you want to exclude and go to Properties. The category ID number will be at the very end of the address line.
1 | <?php wp_list_categories('exclude=10,12'); ?> |
If you would like to show posts from each category, a great plugin that I use on Arbenting is Latest Post from each Category. With this plugin you can choose how many posts from each category you would like to display including the option to list every post from each category.
Most Popular Posts
It is always helpful to direct your visitors to your most popular posts because the content has proven to connect with a range of people. For this you will need the WordPress Popular Posts Plugin.
Then place the following code wherever you want to display your most popular posts. This default will have an h3 header Popular Posts and will list 5 posts via their linked titles.
1 | <?php if (function_exists('WPPP_show_popular_posts')) WPPP_show_popular_posts(); ?> |
You can also alter these parameters with the options listed at the plugins FAQ page.
For example, the following code will have the h4 header Our Most Popular Articles and will list 10 posts via linked titles as well as the number of views the post has received.
1 | <?php WPPP_show_popular_posts( "title=<h4>Our Most Popular Articles</h4>&number=10&format=<a href='%post_permalink%' title='%post_title_attribute%'>%post_title% (%post_views% views)</a>" );?> |
Most Commented Posts
Highlighting your most commented posts will direct your readers to the most active discussions on your blog, sparking more interaction with your audience which is always beneficial in building a strong readership.
First, you will need to install the Most Commented plugin.
Then insert this code wherever you would like the posts listed. This will show the 5 most commented posts on your blog. You can also alter this number to however many articles you would like to display.
1 | <?php mdv_most_commented(5); ?> |
Highlight Your Favorite Posts
If highlighting posts that are your personal favorites is a route you want to go, you will need to create a category titled something like Favorites, and then add all of the posts you want listed here into that category. Using the following code will list all posts in your Favorites category.
1 2 3 4 | <?php $my_query = new WP_Query('category_name=Favorites'); ?> <?php while (have_posts()) : the_post(); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a> <?php endwhile;?> |
A Search Box
And just in case the reader still does not find what they are looking for on the page, it is nice to provide them with a search box.
If your theme doesnt already have a searchform.php file, you will need to create it. Simply paste the following code into a new text file and save it as searchform.php in your theme folder.
1 2 3 4 5 6 7 | <form id="searchform" method="get" action="/index.php"> <div> <input type="text" name="s" id="s" size="15" /><br /> <input type="submit" value="Search" /> </div> </form> </li> |
Then, paste the following code wherever you want the search box to appear in your theme.
1 | <?php include (TEMPLATEPATH . '/searchform.php'); ?> |
Wrap Up
So, here is our final archives page template. Obviously you will need to create some styling elements to style the page to match your clients theme.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | <?php /* Template Name: Archives */ ?> <?php get_header(); ?> <div id="archives"> <h3>Monthly Archives</h3> <?php wp_get_archives(); ?> <h3>Archives by Category</h3> <?php wp_list_categories(); ?> <?php WPPP_show_popular_posts( "title=Posts by Popularity&number=5&format=<a href='%post_permalink%' title='%post_title_attribute%'>%post_title% (%post_views% views)</a>" ); ?> <h3>Most Commented Posts</h3> <?php mdv_most_commented(5); ?> <h3>My Favorite Posts</h3> <?php $my_query = new WP_Query('category_name=Favorites'); ?> <?php while (have_posts()) : the_post(); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a> <?php endwhile;?> <h3>Search the Blog</h3> <?php include (TEMPLATEPATH . '/searchform.php'); ?> </div> <?php get_sidebar(); ?> <?php get_footer(); ?> |
Now that you have the template complete, upload it to your theme folder, log in to wordpress admin and create a new page. In the right hand column you will see Template listed under Attributes. Choose the Archives page, give the page a title and simply publish.
What have you done with your archives page? Feel free to show off links in the comments!
Enjoy this post? You should follow me on Twitter!
I’ve just done the complete listing. Simple yet a lot of people hae found it useful.
http://churchcrunch.com/archives/
Hey nice one site buddy… very nice layout… very spacious… likely more oxygen in web to breathe haha :D btw the footer effect of jquery on hover neon glow is cool… really… i too made this wordpress custom theme for my own project http://www.rockpakistani.com... hows my layout… i will be implementing my layout archives via michaels blog… thankyou *michael….
btw im talked about the crunch one really impresive layout buddy… thumbs up!
Great post – I’m starting to build up my archives and this’ll be very helpful in the future.
Thanks a lot! I hope it comes in handy while you’re building your archives :)
Thanks Angie :)
Good post. I currently don’t have an archived page on my blog. Will refer to this post once I decide to add it on. Thanks!
Nice share I will also refer to this in the future. It looks very handy. Thanks for sharing.
This is a helpful tip, but one thing to keep in mind is that having 100s or 1000s of links on one page can be bad for search engines. I would consider restricting the archive page you create by either robots.txt or the robots nofollow, noindex meta tag. But a great usability tactic nonetheless.
Thanks so much for this tip, it’s not something I had thought about before but I’ll definitely be excluding my archives page from search engines now.
Mark there is a plugin called Nofollow archives.You can do this with the help of this plugin.
Actually, if you use the plugin Headspace 2 (it’s free) then there’s no need to nofollow your archives as it keeps you from getting duplicates as well as making google think your spamming. And that way, you’re have equal pagerank on all of your pages.
very useful
thank you
Thanks for all of the comments everyone! I’m glad you’re all finding the tips useful :)
Thanks for writing it Angie, I’m loving the post as well! :D
Useful :), will refer in future
what about archives by post tags?
I use pretty much the same setup on my archives page for Guerrilla Freelancing. A little bit of everything, the person is sure to find what they’re looking for :)
http://www.guerrillafreelancing.com/archives/
I need to update it though with a two column layout for the categories and monthly archives, so the page doesn’t stretch so far down the page.
Cool post Angie :)
The two column layout is a good idea for blogs with a lot of content, might try that out here sometime as well! :)
That is a great idea Mike! I still need to do some work to Arbenting’s archives (I’m like a carpenter who’s house needs work hehe) and will look at implementing a 2 column archives page.
Really Nice Post Angie
Wow, excellent post and very detailed. I usually pay minimal attention to my archives page but I suppose maybe I should reconsider. I just figure people don’t really visit it. But of course for the sake of good design it’s good practice to make it as functional as possible for those who do use it. Oh and as far as the duplicate content issue, you could also use canonical tags rather than nofollowing/noindexing the whole archive. -Rob
Thanks for the tip on Canonical tags, I’ll definitely look into that.
Thank you, easy to follow and understand
Can i use this format to my blog, that is blogspot
Sorry, the code examples here only work for WordPress. You could achieve the same effect in Blogger most likely, but the method to do it would be different.
Very good post. Old posts are far too often overlooked. Including a note in your about page linking to some of what you have above is a good idea. I agree completely that you want to make it easy for a new visitor to find other content they would like. Related links in the post, categories and popular posts are 3 great ideas.
Not bad. The unique complete site map for visitors, but not for poskovikov! The only thing even individual styles prescribe.
Nice.Simple and yet useful.
Thanks Angie,
I am guessing if i want to show a specific post i should do the following:
[code]
<a href="” rel=”bookmark” title=”Permanent Link to “>
[/code]
Am i right??
Thanks again.
Yes, you can do specific posts that way, though anytime you want to change the post, you’ll have to manually edit your archives page. You can also use the technique outlined under “Highlight your Favorite Posts” so that anytime you want to change the posts listed, you just have to change the posts categories.
I am sorry seems that the php code sample has been removed.
I meant if i did change:
new WP_Query(‘category_name=Favorites’)
To
new WP_Query(‘post_name=myPostName’)
I should be able to show a specific post! Am i right?
Hmm, I’m honestly not sure about this. Let me look into it and I’ll try my best to answer :)
Sweet blog! I love the design here and I’m really impressed with the post, keep it up
Thank for the tip!
http://www.forexrobotmarketing.com/forex-robots/fap-turbo-review/
Looks like a very clear explanation. Creating WordPress templates is something I should have learned earlier. I’ll give it a start with this tutorial!
I love this tutorial, you really need to have a lot of ways to sort or search archives.
Thanks for the information. I leave a TON of posts on my blog (sometimes two a day) so having a good way to archive them in a must.
The old way I was doing it was horrible to say the least. Your tips here are going to make my blog much more enjoyable for my readers. Thanks a lot.
It´s really important to have a good organized archive otherwise the readers will loose their interest if it´s to hard to find.
Thanks a ton for this post, it has been very useful.
awawaw…
yess.. i need this tutor.. thank for share
nice post thanks for sharing this.
thanks for post really nice.
This is a great post but the problem is I am unable to find Page Template option in my page admin panel. I am using WordPress v2.8.6.
Maybe I thing its a bug in version.
The most useful archives should be on Magazine Themed blogs, this advices/codes are pretty cool and very useful, I’m just going to say thanks a lot for this post.
Why not use the SRG Clean Archives plugin which lets you list every post by month and comments as well?
Currently, I don’t have an archives page on my blog, which is hosted by WordPress.com. However, my new upcoming site should have an archives page because it will be powered by self-hosted WordPress.
I like the tips and that you wrote the code yourself! No need to change anything for us non-techies. :-)
I’d love more WordPress tutorials like these to be posted here more often. In my opinion, list posts have been done enough here. Thanks again for the code!
hi, thankx for the post.
But i have a Problem. on my website [ http://gfxtutor.co.cc/archives/ ] whn i click on ARCHIVES it opens Contact form page. !!! how do i solve it !
Im using name Permanent link style.
Thanks for the tip. I’ve never been happy with my archive and am going to try and incorporate this.
Good luck Erika, hope it turns out well!
Thanks, Angie, for the tip! It is very nice of you for sharing that with us!
If you’re using any sort of content management system to blog, then you need a usable and efficient archiving system, or your new visitors will not be able to find your older content without trawling for hours. No-one wants to do that. All it takes is a sensible search function and the breaking down of older blogs by month/year and/or category.
yeah it is important that you have a easy and friendly archives, so that readers will still stay on your website and can explore more of your content. Blogger put much attention on creating lot of content and neglecting some parts of the website.
Very useful tips! Thanks Angie!
Excellent. I’ve been thinking about reworking the archives at Indyposted.com for a while. I can’t use all the info, as I already have custom images at the top of the page, but the coding here is more clean, which is always a big consideration. Time to start some new coding. Thanks :)
Excellent. I’ve been thinking about reworking the archives at Indyposted.com for a while. I can’t use all the info, as I already have custom images at the top of the page, but the coding here is more clean, which is always a big consideration. Time to start some new coding. Thanks
Thanks for the tip, great for older wordpress-verisons.
hi, i’m a newbie in wordpress. i want to ask, how can i see my archives?
yeah it is important that you have a easy and friendly archives, so that readers will still stay on your website and can explore more of your content. Blogger put much attention on creating lot of content and neglecting some parts of the website.
actually i wonder add archives links no foloow how to add no follow my archive links
thans you admin.
great stuff!
Like the others have said. While it is quite expensive, it is one of the best frameworks!!!!!
If I enable the archives on my blog, can I be penalized for duplicate content with Google ?
Blog archives are good to have. It helps the visitor to get easy access to all your old content
This is what I need in creating a powerful archives in wordpress. I’m glad that you shared it with us.
Yet another useful post that I find on this website. I liked the wordpress header as well as the tips and advice offered here, and now that I think about it maybe people really should give more attention to their archives.
thans you admin.
Really helpful information
If I enable the archives on my blog, can I be penalized for duplicate content with Google ?
just add nofollow to links to archived pages, so google does not index the page and do not see any duplicate content on the page. My problem is also confused how to add nofollow on wp_get_archives. LOL ^_^
What about adding nofollow in wp_get_archives? how we can do that?
I think this is a good thing for google not to index the archive pages to avoid duplicate content or meta.
Hello,
I have this archive.php. How do I change it so that the articles that appear on the page don`t overlap.
Thank you very much!
<div >
“alignleft post_thumbnail”)); } ?>
<h2 class="title" id="post-“><a href="” rel=”bookmark” title=”Permanent Link to “>
<img src="/images/date.png” /> <img src="/images/user.png” /> ID)) { ?> <img src="/images/edit.png” />
<?php else :
if ( is_category() ) { // If this is a category archive
printf("Sorry, but there aren’t any posts in the %s category yet.”, single_cat_title(”,false));
} else if ( is_date() ) { // If this is a date archive
echo(“Sorry, but there aren’t any posts with this date.”);
} else if ( is_author() ) { // If this is a category archive
$userdata = get_userdatabylogin(get_query_var(‘author_name’));
printf(“Sorry, but there aren’t any posts by %s yet.”, $userdata->display_name);
} else {
echo(“No posts found.”);
}
endif;
?>
Awesome post…. Thumbs up!!! love problog… keep it up… michael.. !!!
Great content! I just came across your blog and actually read your posts! I wish you would post more often. It is hard to find good informative blog like yours! Thanks for the information.
Very usefull tut! Thank’s for the explained info
thans you admin.
thankx for the post.
thank you admin good sharing
Thanks Angie for spending your effort to make this easy. I could imagine a blog so messed up without an archive. Your post is a must read.
I have created an “articles of interest” page to avoid having to use too many categories and get nailed for duplicate content and also to avoid having to put an archive menu on the front page of which I was told the spiders don’t like.
Good work! I always like to leave comments whenever I see something unusual or impressive. I think we must appreciate those who do something especial. Keep it up, thanks
Helen Olsson
science
Hi Angie,
What would I use if I just wanted to display my blog posts normally? Would archive.php be better for this?
Thanks :)
I need a plugin that will show calender and when i click a date of the calender then it will show the post of the pages of the specific category.
Is there any plugin like something that ?
But above code will helpful for my future task.
My web site is http://www.bd24live.com . I can’t make a archive page. Any body help me?
thank you admin good sharing
Hey. Thanks for all the great tips. So i kinda thinking that i want to put a post or a picture on the “home” pge, thenn put it in the categori “love” and then it would end up as a post on the page named “love” as well. Is that at all possible? And is it also possible NOT to put all the dates and comments and ommercial underneath the post. So there’s just a space after a post?
Thanks.