wpthemedetector-logo
WordPress Theme Detector Blog

How to Create a WordPress Archives Page

31 comments

The chronological nature of blogging means that great articles can get lost in your archives. Placing a search bar and an archives widget in your sidebar can make it easier for visitors to search through older content.

You can extend this further by creating a dedicated archives page. Unfortunately, not every WordPress theme comes with an archives page template and those that do are not always structured the way you want.

Thankfully, it is very easy to create your own archives page. All you have to do is create an archives page template and then assign it to a page.

In this tutorial, I would like to show you how you can build an archives page for your WordPress website.

Check If You Already Have an Archives Template

Before we get started, I recommend checking whether your current WordPress theme already has an archives template. This will help you determine whether you need to create an archives template from scratch or simply modify an existing archives template.

The quickest way to see if your activated WordPress theme has an archives template is to create or edit a page (not a blog post!). At the right hand side of the post editor you will see the Page Attributes menu. This allows you to assign a custom page template to any WordPress page.

If your activated WordPress theme already has an archives page template, you will see an option for an archives template. The name of the archives template depends on what it has been named in template itself. Usually, it is named Archive or Archives.

Archives Page Selection

Selecting the Archives Page Template

Many themes do not include an archives template, though WordPress users may be led to believe they do because they include a template named archive.php. Take the default WordPress theme Twenty Fourteen, for example.

If you modify a page, you will see that the theme does not include an archives page template. However, a quick look at the templates of of Twenty Fourteen highlights that it has a template called archive.php.

Twenty Fourteen Templates

Twenty Fourteen does not have an archives template.

In WordPress, the archive.php template is an important template that is placed highly in the WordPress template hierarchy. The only template with more importance is index.php.

WordPress allows you to display older blog posts in a number of ways. Category archives can be displayed using the category.php template and tag archives can be displayed using the tag.php template. Whereas date archives use date.php and author archives use author.php. None of these archive templates are essential.

If WordPress does not find any of these archive templates in a WordPress template, it will use the archive.php template to display archives instead. And if for any reason an archive.php template is not available, WordPress will use the index.php template to display archives.

WordPress Template Hierarchy

The archive.php template can be used to display a range of different archives on a WordPress website.

In contrast, the archives.php template is a page template that can be assigned to any page. It is used to create a dedicated archives page.

  • Archive.php – Used to display category, date, author, tag, taxonomy, and custom post type archives
  • Archives.php – A page template that is used to create a dedicated archives page

Despite these templates being used for completely different purposes, they are regularly confused by WordPress users due to their names. To avoid this confusion, many WordPress developers name the archives template something different, such as page-archives.php or archives-template.php. This is not necessary as after you define the file as a page template, WordPress will append the word template to the file in your theme file editor.

Creating a Basic WordPress Archives Template

If no archives template exists, you should create a blank file and name it something like archives.php or page-archives.php. If you had to upload that blank template to your WordPress theme directory, you will see the file listed in your template list.

Blank Archives Template

What you will see in your theme editor when you upload a blank archives template file.

Like all WordPress page templates, the name of the template that appears in the Page Attributes section of the WordPress page editor is defined using the Template Name string.

In the example below, I have named my archives template Archives; however I could have named it anything. This code would be placed at the top of our PHP page template.

Once you have defined the template name in the archives template, WordPress will show that the file is a page template.

A Named Archives Template

Once you have defined your archives template as a page template, WordPress will highlight it has a template in the WordPress theme editor.

The most practical way of creating an archives page template is to modify the code of your WordPress theme’s page.php template. The Creating an Archive Index tutorial in the WordPress Codex gives an example of this.

As you can see from the code below, this archives page template would display a search form, archives by month and archives by category.

The above code is a good example of an archives page template, however the exact code of your archives page template will depend on the theme you are using. If you used the above code for an archives page template with your current theme, it is unlikely to be styled correctly as it is not based on your theme’s page.php template.

In practice, creating a custom archives page template is slightly more complicated. This is particularly true for themes that call the content of page templates from different files. For example, in Twenty Fourteen, the content part of a page is stored in a file entitled content-page.php.

If I wanted to create an archives page template for Twenty Fourteen, I could place all code in the archives template or call the content for archives from a new file I create entitled content-pagearchive.php. Neither option is better than the other. Simple use the method that you feel is best.

While placing code in specific content templates is tidier, I prefer to place all the code for the archives page template in one file. Here is an example of a simple archives page template I created for the Twenty Fourteen theme.

At first glance, the above code may seem complex; however it is actually straight forward. All I did was copy the code from page.php, replace the call to the page content template tag with the code from content-page.php, and then insert the code to display archives.

You can repeat these steps with any WordPress theme in order to create a unique archives page template for your website.

Customize Your Archives Page

There are a number of WordPress template tags that can be used in your archives page template. This includes:

A wide number of parameters are available for each template tag. This allows you to customize your archives page as you see fit.

For example, you can display monthly date archives using:

You can display all pages in a list by using:

You can list authors by post count by using:

A search form can also be added to your archives page by simply using the get_search_form function. This reminds visitors that they can search through your content by entering a search term.

It is up to you how complex you make your archives page. You can list as little or as much information as possible. You could also place information into columns using tables.

Publishing Your Archives Page

Once you have created an archives template, you need to create your archives page. All you have to do is create a WordPress page and ensure you choose your archive template as the template.

A small description can be added to the top of your archives page. This could be placed in the archives template itself, however it makes more sense to add the description to your page as it is easier to change it later. It also makes the process of formatting text and inserting images simpler.

Create an Archives Page

It only takes a minute to publish your archives page.

This is an example of an archives page I created for the Twenty Fourteen WordPress theme. You can create something similar yourself in just a few minutes.

An Example of an Archives Page

This is an example of a simple archives page that splits the archives into two columns using a table.

Overview

An archives page presents multiple ways for visitors to find content on your website. And by helping visitors find what they are looking for, you can retain visitors on your website longer and increase pageviews considerably.

If your WordPress theme already has an archives page template, you can use archive related template tags to make your current archives page even better. Do not be too worried if your theme does not have an archives page template as the process of creating one is relatively simple.

I hope you found this tutorial useful 🙂

Kevin

Follow Me

Kevin Muldoon

Kevin Muldoon is a professional blogger with a love of travel. He writes regularly about internet marketing on his personal blog and on the internet marketing discussion forum Rise Forums.
Follow Me

Latest posts by Kevin Muldoon (see all)

Liked this post? Please share it!

31 Comments

  1. Hi Kevin Muldoon,
    Clean and perfect example to create archives page in blogs,good work keep it up,we are expecting more fantastic Articles like this,but you are writing posts monthly once in this website,its really disappointment to us…Don’t mistake me,its our humble request try to write more posts in this website.

    • Thanks for the kind words Shanthi. I will do my best to publish more tutorials here for you 🙂

      Kevin

  2. Thanks Kevin for a great tutorial, and welcome to the WPTD Blog!

    For those of you regulars of this blog who know Kevin Muldoon and enjoy his valuable articles about WordPress, I´ve got goods news: This is the first post by Kevin on this blog, but it won´t be the last one!

    And for those of you who don´t know about him yet, I´ve got good news too: You´re going to love his articles.

  3. Thanks Luis. Great to be here 🙂

    Hope you all enjoyed the tutorial.

  4. Thanks Kevin for your great and useful article. Seriously i was looking an article related to archives creation page. I found so many articles on the internet but all they were very confusing and complicated. But now after reading your article i am pretty sure that i can create archives page for my blogs.
    Thanks again Kevin and keep updating this type of useful articles.

    • Your welcome Bhawna. Glad you enjoyed the article 🙂

  5. I’ve create the custom archives page and added the page to wordpress. I can also select the archives page as a template and have published the page. However, when I try to view the archives page it tries to load forever and eventually times out.
    Is there something I am missing in the functions.php code or somewhere else?

    • ok, so I was confused, and was able to solve the previous issue. I have a basic template working, but it does not load my sidebar alongside the content. It pushed it down the the very bottom on the screen.

      Is there a problem with the divs? http://thenerdynurse.com/archives

        • I used a plugin – I would have prefered to code in manually. However, your article was the one i found which clarified the difference between archive.php and archives.php – thanks so much for that!

  6. Thanks Kevin for this article.

  7. hi, yes this is really great. An Archives page is really helpful web explorers..

  8. Hello Kevin,
    Great to have your informative postings!
    I have a site-map.php template but it’s very plain. Would love to ‘spruce’ it up and put the info into sections that not only look good, but are helpful, of course, to my visitors. I am wondering if it wouldn’t be easier to create a NEW site-map(archives template) and style it the way I want? Or would it be easier to copy the archives template into my child theme and modify it?
    Thanks again for the useful information – looking forward to more from you!
    ~ freida

  9. Best poster about creating file description. Explained and easy to understand as well.

  10. All double dutch to me as a newbie, so all the more reason to create an archives template. tku so mch kevin. great work it seems.

    mary (Ireland)

  11. Hi Kevin,

    Thanks for the great article, it was very helpful!

    Using your code, I created three separate archives — one for category, person, and month.

    You saved me a ton of time. Thanks again!

    🙂 Jennie (aka tanster)

  12. Thank you for this tutorial , I’m an avid reader and learner of WordPress and blogging , and this article explains it very nicely.

  13. Thanks for this, it’s really depressing staring at archive(s).php for hours and not understand what’s going on or even if you’re in the right place – the art is knowing what to Google, in the end it was “archive.php tutorial” that brought me here – really simple!
    You made my day, the sun’s shinning (for me) again.

  14. Hi, This article contains an interesting diagram – The archive.php template can be used to display a range of different archives on a WordPress website. – which seems to contain alot of useful information, but unfortunately it’s totally illegible, would it be possible to receive an enlarged version

    Thanks
    David

  15. Hi Luis Nice guide will Try this on my blog ..Thanks for the Tutorial…

  16. How do you actually upload the .php page template you create? I can edit an existing file for my theme, but I can’t see how to upload a new one. Thanks!

    • Hi, Angela.

      If you need to upload a new PHP file you´ll need a ftp connection to your server.

  17. Thanks Man Much Help .

  18. The archives page process is very.God I was searching for the same since hours.

  19. Another very good WordPress plugin that can handle this function is “WP Sitemap Page” its a free plugin that displays your site archives in any page or post with a lot of options that will help you to customize the WordPress archives page.

  20. Thats i want it sir, before i’m very confuse to know what my client want from looking another site

  21. what is the purpose of archive? will it help in minimizing the resources?

Trackbacks/Pingbacks

  1. How to Create a WordPress Archives Page | Ventisqueros Digitales - […] Origen: How to Create a WordPress Archives Page […]

Submit a Comment

Your email address will not be published. Required fields are marked *