Beginner's Guide for WordPress / Start your WordPress Blog in minutes

How to Create a Custom Archives Page in WordPress

Custom archives page is a great way to bring together all your old content in one page. It allows you to have a dedicated page where you can list your monthly archives, category archives, tag archives, author archives, and anything else that you might want to add. We have a custom archives page for WPBeginner. Recently one of our users suggested that we write a tutorial on that. In this article, we will show you how to create a custom archives page in WordPress.

The Problem

By default, you have the ability to display your yearly archives by using sidebar widgets. This can get out of hands once you have been blogging for more than a year. Imagine sites like WPBeginner that have been active for nearly 4 years. We would have 48 monthly archive links in the sidebar. You also have the ability to add category archives, author listing, etc on your sidebar. But why clutter the sidebar with so many links when you can create a single page to list them all. This is when a custom archives page come in play. Not only does it allow you to avoid clutter, it also provides your users with an efficient way to browser through your older content.

Sadly, most WordPress themes do not come with a custom archives page template. Let’s look at what you need to create a custom archives page template in WordPress.

Note: Please do not confuse the custom archives with archive.php template that comes with most WordPress themes. The archive.php template is used to display monthly, category, tag, author, and other archive pages. Our custom archives page would be a single page that will bring all of your other archives together.

Creating a Custom Archives Page Template

First thing you need to do is to create a page template for the custom archives page. Simply open a new file in your text editor (i.e Notepad) and name it page-archive.php. Next, Add the following lines of code at the top:

Template Name: Archives

Upload the page-archive.php in your WordPress themes folder, and you have created an Archives page template. Now we need to make sure that this page template matches the design of your site. Copy the content of your page.php file located in your theme’s folder and paste it in page-archive.php.

Below is an example of how your page-archive.php file would look like:

Template Name: Archives
get_header(); ?>

<div id="primary" class="site-content">
<div id="content" role="main">

<?php while ( have_posts() ) : the_post(); ?>
<h1 class="entry-title"><?php the_title(); ?></h1>

<div class="entry-content">

<?php the_content(); ?>

/* Custom Archives Functions Go Below this line */

/* Custom Archives Functions Go Above this line */

</div><!-- .entry-content -->

<?php endwhile; // end of the loop. ?>

</div><!-- #content -->
</div><!-- #primary -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

Creating a Custom Archives Page in WordPress

Now that you have the basic page template ready, you need to create a new custom archives page in WordPress. Go to your WordPress admin panel and add a new page (Pages » New). You can call this page Archives, Library, or anything else that you like. Now look at the meta boxes below the publish button on the right hand side of your screen. You should see a meta box called Page Attributes. Click on the drop down menu below Template and choose Archive as your page template. Save and Publish the page.

Select Archives Page Template in WordPress

Now you have created a page that uses the archives page template, however it will not show any content. Let’s go ahead and add custom archive page elements such as yearly archives, categories, etc.

Adding Monthly Archives with Compact Archives

If you look at our custom archives page, then you will notice that we are not using the default monthly archives listing that comes with WordPress. Instead, we are using a plugin called Compact Archives. Note we have adopted this plugin and are now maintaining it.

Install and activate this plugin the Compact Archives plugin. After activating the plugin, add the following code in your custom archives page template (page-archive.php):

<p><strong>By Date</strong></p>
<?php compact_archive($style='block'); ?>

It will display your monthly archives like this:

Displaying monthly archives one year per row using Compact Archives

Adding a List of all Categories

Categories summarize the main topics of your website and are the best way to sort your content. See why how we use Categories vs Tags. Since we are using categories as the main way to organize our content, we think it is absolutely crucial to list our category archives. To save space, we are going to display it an inline list.

First add this code in your archives page template file:

<ul class="bycategories">
<?php wp_list_categories('title_li='); ?>
<div class="clear"></div>

Now we need to style this list, make it appear inline and improve their look. Add this to your theme’s style.css file:

ul.bycategories {
margin: 0;
padding: 0;
ul.bycategories li {
list-style: none; 
list-style-type: none;
margin: 0; 
padding: 0;
ul.bycategories li a {
list-style: none; 
list-style-type: none;
margin: 0 20px 15px 0; 
float: left; 
background: #eee; 
color: #464646; 
padding: 5px 10px;
border-radius: 5px; 
-moz-border-radius: 5px; 
-webkit-border-radius: 5px;
ul.bycategories li a:hover{
text-decoration: none; 
background: #ff6200; 
color: #fff;
.clear{clear: both;}

Your categories will look like this:

Displaying in line categories on archives page in WordPress

Explore? Redirect Users to a Random Post

In our archives page, we have an Explore WPBeginner button. This button redirects users to a random post. The purpose is to allow users to randomly stumble through articles. Learn how to redirect users to a random post in WordPress.

While this is all the information that we have on our custom archives page, you can most certainly add more. Let’s look at some of the other things that you can add.

Adding a Tag Cloud

If you want to display a tag cloud of your most popular tags used on the site, then simply add the following code in custom-archive.php file:

<p><strong>Tags Cloud:</strong></p>
<?php wp_tag_cloud(); ?>

The wp_tag_cloud() function comes with a lot of parameters to adjust the number of tags, maximum and minimum tag sizes, etc.

Adding a List of Pages

If you want to display a list of all pages on your site, then simply add the following code:

<?php wp_list_pages( 'title_li=' ); ?>

Adding a List of Authors

To display the list of authors on the site, simply add the following code:

<?php wp_list_authors( 'exclude_admin=0&optioncount=1' ); ?>

Adding Recent Posts

If you want to display a list of your most recent posts, then add this code:

<?php wp_get_archives('type=postbypost&limit=10'); ?>

A comprehensive archives page allows your users to efficiently navigate through your old content. We hope that this article helped you create a custom archives page in WordPress. If you have any questions or suggestions, then please let us know by leaving a comment below.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit – a collection of WordPress related products and resources that every professional should have!

Reader Interactions

79 CommentsLeave a Reply

  1. Thank you for this helpful tutorial. I do follow along and have my custom archive page up. However, I still get the default WP archive under my custom settings. Could you please have a look and tell me what have I done wrong?

    Thanks for your kind reply.

    —Woolker Cherenfant

  2. I wonder if anyone can help?
    hopefully someone might be able to help with an unusual problem that I have noticed – and it appears to have been occurring since Nov 2017 or before…
    For example…
    this url has been generated/created and I don’t know how or why… it seems that with two categories if I take a ‘whole’ url and copy and paste that after the category part only url then it will resolve… (and has been indexed!)


    I think this has only happened with (archive) pages…

    To make matters worse these urls have been indexed by Google. I don’t know if a plugin has caused this or something else…

    Note the single ‘/’ in the second part of the url…

  3. Wonderful tutorial! Thanks so much.

    Quick, I hope, question: I used your instructions for adding “Adding a List of all Categories.” How can I get my list itself to show justified inside the space, instead of left aligned. Thanks for any help.

  4. This worked great, but I want to display an actual snippet of the archived pages instead of just a list. Is there a way to do that?

  5. Thanks for this useful article, I have one problem Add code to my theme’s style.css file, Where should I paste it exactly ? because I’ve tried to paste anywhere but nothing change!

  6. Can this be done with a free WordPress account, or do you need the customising options of one of the paid plans?

    Thanks if you can let me know :)

  7. Hi !

    I’m preparing a news site with WP theme but I have a GREAT question about archives, maybe you’d be able to give me your opinion thanks to your experience.
    The site must give a new version everyday (relating to the paper edition) and offer an archive page which allows to find the old editions as it was published the day ‘d’. Plugins in WP allow only to have articles by date, so we have a list of the old artilces for a specific date but not the whole edition (a complete copy of the site as it was published at a ‘d’ date). Do you know any plugin for WP to ‘make a copy’ of a site so it’d be possible to link every ‘copy-date’ with a date in the calendar table? or an archive plugin to have automaticly the old editions ? Is it possible to have a folder (in the WP repertory) which contains all the articles of an edition ? so I can link each folder to a date in my calendar table ?
    – Do you have in your favorite lists a good WP theme for newspaper ?
    Thanks in advance !

  8. Upload the page-archive.php in your WordPress themes folder, and you have created an Archives page template.

    I am having difficulty with this part. How do I upload the page-archive,php in the wordpress themes folder?

  9. Hi there

    This worked great for me! Thank you.

    One thing though, My list of archives will not show on mobile devices. I am currently running the WPTouch plugin for mobile users.

    Could you advise how to resolve this please?


  10. Hi, is there a way just to list certain categories i.e. exclude some categories from the list?
    Thank you.

    • yes you can use wp_list_categories function like this.

      <?php wp_list_categories('exclude=4,7&title_li='); ?>

      Replace 4,7 with the IDs of categories you want to remove.


  11. Hello,

    I have registered different CPT.

    I have created a page template which list posts for a given CPT.

    I have put a query (query_posts(‘posts_per_page=-1&post_type=my_cpt_one’); before the loop.

    Than I have selected the page template when creating the page archive of the given CPT.

    How to use the same page template for each CPT?

    For example, I want three page archive named “my cpt one”, ‘my cpt two”, “my cpt three” which calls the same page template.

    Of course, i could use three page templates, but I’m looking for a way to use only one page template.

    My problem is to set in the query the post type slug.

    Is that possible?


  12. That’s because template tag wp_list_categories generates a bulleted list of your categories by default. Child categories are displayed indented under their parent categories. You can use
    &lt?php wp_list_categories('title_li=&style=none'); ?> to display your categories with line breaks.

  13. Cant we make it without plugin? I just want to list my all of posts in one page. No matter there is 10000 posts or 2 post. i just want to list ?

  14. I would like to create an yearly/monthly archive of a specific category. Is it possible using with a filter for a specific category?

  15. I am looking high and low for my themes folder… I know a
    little more than basic for coding, but working with WordPress has been
    difficult for me trying to find everything. Maybe it is not compatible with
    what I have.

    I am trying to have a page on my blog for a list of Archived
    blog posts that looks like this: with year,
    month, and categories. I have a lot of posts. I tried the plugin
    for Archives and created a page and added [archives] and all I got was a whole
    list of all my blog post titles. It was long.

    I found this post
    but I cannot locate a themes folder in wordpress. Maybe I have the wrong set

    I am hosted with one of the outside WordPress recommended
    hosts using WordPress for my blog. My theme is Twenty Ten.

    If someone could help me get the result I am looking for,
    that would help me a lot. Thanks!

    • If anyone is looking for an answer to this. The path is :

      WordPress root folder -> wp-content -> themes -> Twenty Ten

  16. I have just added archive page to my site but want the posting pages, dates and categories hidden and only visible when you log in. My post pages currently show blocked but I see them in public view. Can these be hidden???

  17. Works Perfectly, When I tried to add &show_count=1 then the count breaks the category listing .. can you help with the css needed for the count to display properly.

  18. Very helpful. I have just added archive page to my blog site
    Question: Would this template file get deleted during theme upgrade?

  19. I love this tutorial! However, I want my tag cloud to be separated by commas. Here’s the code I used for the tag cloud (I don’t want the font sizes to change so I kept the smallest and largest at the same size)…


    Any tips?

    • Your code was stripped by WordPress comments. This snippet should work:

       $args = array(
          'smallest'                  => 8, 
          'largest'                   => 22,
          'separator'                 => ','


  20. Hi, thanks for the great tutorial!

    I did set-up the list of all categories which looks perfect. The only problem I have is that if I add any content to that page, the list of all categories is always placed at the bottom. Is there a way how I can set it to the top of the page?

  21. Hello guys,
    First of all, thanks for this amazing website. I have used this post to create the archive but since yesterday the archive page is no longer working. I have not changed the code and now the only thing I see is By date. after that, I cannot see anything, not even the sidebar or the footer.
    My template is running locally as I am building it. Any idea what could have caused that?


  22. I copied your given code but my site is not showing any kind of archives. Your code has an error. 0n line # 16 you are closing ?>php then starting html, which will simply print html on page. I activated plugin, corrected the code but still my page is empty. Let me correct, thanks.

  23. Awesome. I’ve got to bookmark it and come back, but an archves page is something I’ve been wondering about for a bit now.

  24. Great tutorial. Could you clarify something before I begin. I’m using a child theme. Should I add the page-archive.php file within the folder of the actual “theme files” or should I place it within the child-theme-folder? Likewise….Now we need to style this list, make it appear inline and improve their look. Add this to your theme’s style.css file. I’m going to assume I can add this within my child-theme as custom css; is that the correct approach?

  25. I’d like to combine the two archive display ideas above. I have two categories: Cars and Boats. I’d like to show the monthly archives ( with the Compact Archive plug-in) for each. What php do I use? Thanks.

  26. Great tutorial — thanks :) It has worked perfect!

    I copy and pasted the css provided into my css file and it did not change the look at all. Thoughts?

  27. Thanks so much for this really useful post. I’ve just started using a really minimal theme, so this custom archive page is perfect to help navigation. It’s looking good!

  28. Hi,

    Great plugin and easy to use.

    I am trying to use it for a custom posts archive page (only the custom posts to be listed in years, by month.

    Does this work with custom post types at all? Currently it is only listing regular post types.

    With thanks :)


  29. I do not understand where to upload my page-archive.php file. Where is the WordPress Theme folder?

  30. I have created Archives.php and when on the page i click on the archives i don’t get which template is the posts using (custom posts) ,its a mess actually. Could you please help.

  31. i see you are using the_content in the loop, but when you click on a month and see the posts, it is only showing a snippet. Is that controlled via another custom function? Could I instead use the_excerpt?

    TIA, very useful post

  32. Well… This post is quite useful but I got problem… I have Thesis 1.8 theme and I am not able to find page.php file in my theme folder …. Sad… Any ideas…

  33. Syed, you are doing a great job for the beginners, and I think its a great service specially for the very non skilled just like me. Masha Allah and JazakAllah!

  34. Is there any way to limit the output from Compact Archives to one category of posts instead of all posts?

  35. I found it too difficult to add to a Woo Theme. The Woo Framework page.php is too complex to work out where the additional Compact Archives code goes. It doesn’t have a nice commented slot as does the sample in the example.

  36. So timely! In the last fortnight I have been frustrated at how difficult it can be to view archive posts in time sequence and some other ways. And I wondered whether my readers were having the same issue. I’m not into adding code but will make an exception in this case. Thanks.

Leave a Reply to Avinash Cancel reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.