Creating a Custom Archives Page in WordPress

Nadejda

Nadejda Milanova · 15th April 2021·Wordpress

Creating a Custom Archives Page in WordPress

Having an archives page is an excellent way to combine all of your old content in one single page. It gives you the opportunity to create a page where all of your archives are listed – category archives, monthly archives, tag archives, etc.

Usually by default, you have the option to display yearly archives with the help of sidebar widgets. This can become a bit difficult if you have posts more than a year old. You can also add author listing, or category archives on your sidebar, which, however, will only lead to cluttering the sidebar with tons of links. This is why it’s best to just create one single page where you can list them all. Not only can you avoid unnecessary clutter, but it’s also a great way to navigate through your old content.

As most WP themes do not offer a custom archive page template, today we will show you how to create one yourselves.

How to Create a Custom Archives Page Template?

You need to start with creating a page template for the custom archives page. Open a new file in your text editor and name it page-archive.php. Now, add the following code:

Custom Archives Page Template

Upload the archive php file into your theme’s folder and you have an Archive page template! Next step, is making sure the page will match the rest of your website. Copy all content from the page.php file and paste it in the page-archive.php.

You can see an example of how the page-archove.php file would look like:

page-archove.php file

How to create a custom archive page?

You next step, is creating a new custom archives page in WP. Go to your WP dashboard, click on Pages – New in order to create a new page. Now, check out the meta boxes under the Publish buttonр located on the right-hand side of your screen. You should be able to see a meta box named Page Attributes. Click on the drop-down menu and choose Archive. Don’t forget to save and publish your changes.

How to create a custom archive page

You can now create a page which will use this template, but note, that it will lack content. We will now add some elements such as categories, archives, etc.

How to add Monthly Archives with Compact Archives?

For our example we will be using the Compact Archives plugin. After installing and activating it, add the code bellow in the custom archives page template:

Monthly Archives

You should see the monthly archives like this:

monthly archives exm

How to add a list of all categories?

Categories provide a summary of the main topics on your site and are an excellent way to navigate through your content. If you are using categories to organize your content, it would be best to list your category archives.

You need to add this code to your archive page template file:

list of all categories

Now, you need to improve the design of the list. Add this code to the theme’s style.css file:

design of the list

Your categories should look like this:

categories

How to Add a tag cloud?

If you wish to display a tag cloud of the most popular tags from your website, all you need to do is add the following code in the custom-archive.php file:

tag cloud

The wp_tag_cloud() function provides a number of parameters in order to adjust the number of tags, minimum and maximum tag sizes, etc.

How to add a list of pages?

If you are looking to show a list of your pages, use the following code:

list of pages

How to add a list of authors?

If you want to list all of your authors, use the code bellow:

list of authors

How to add recent posts?

For displaying a list of the most recent posts on your website, try this code:

add recent posts

A good archives page gives your users the chance to properly navigate through your old content. We hope today’s articles was useful in showing you how to create a custom archives page in WP. Drop a comment bellow and let us know what you think!