Codeable info

The Difference Between Archive.php and Archives.php

Posted on by in WordPress Tutorials

When writing a tutorial about creating an archives page last week I was reminded about the confusion which arises between the Archive.php and Archives.php files.

Sometimes WordPress themes have both files in the theme directory though it is quite common for a theme only to have the Archive.php. So what is the difference between these two files?

Archive.php

The Archive.php template is used to display monthly archives, categories, author pages and more. For example, the url www.mysite.com/2010/02/ would display all posts in February 2010 and would be generated by the Archive.php template. Confusingly, the file is called Archives by WordPress, which is where a lot of the confusion arises.

The Archive.php file

It’s worth noting that in the WordPress Template Hierarchy Archive.php comes before index.php in category, author and date displays. That is, if an Archive.php file does not exist, WordPress will use index.php instead.

Archives.php

The Archives.php file is a page template. If you change the template of one of your pages to use the Archives page template you can call certain functions like wp_get_archives(); (which lets you display older posts via day, week, month and year) and wp_list_categories() (which displays posts by categories). It’s worth noting that the Archives.php can be called anything, though it tends to be named Archives.php in themes.

Summary

So if you come across both of these files in your theme and are confused about which does which just remember that Archive.php is the file which controls how older posts are shown when someone clicks on a category link or the older posts link at the bottom of the page. Whereas Archives.php is a page template which lets you call functions which allow you to display older posts :)

)
Codeable info

Comments (1)

Comment by Sam says:

Thank you so much for this! I was pulling my hair out trying to figure out why changes I applied to archives.php were not being displayed when a category/month link was clicked.

In my opinion, the WordPress codex is a little confusing on this issue.

THANK YOU!!!

Codeable info