A guide on how to use, edit and customise WordPress archive titles

This article is a comprehensive guide on how to use, modify and customise WordPress’ the_archive_title() function, used on many different archive views.

What is an archive page view in WordPress?

WordPress has many archive page views. These are views which are dynamically generated rather than having an actual page in the WordPress admin that can be edited. WordPress also has a function which can be used to dynamically generate a title or heading on those pages depending on the page’s context.

Examples of WordPress archive pages

Screenshot of a WordPress archive page showing text and videos.
An example of a WordPress archive pge.

There are many examples of WordPress archive pages, for example:

  • Category – showing post all assigned to a specific category
  • Tag – showing posts all tagged with a specific tag
  • Post format – all posts assigned a specific post format
  • Post type archives – showing all posts from a specific post type when the post type is set to have an archive
  • Author archives – shows all the posts written by a specific author
  • Date based archives – showing all posts for a specific date e.g. all posts published in February 2021
  • Custom taxonomy archives – these show all the posts assigned to a specific term of a registered custom taxonomy

What is the archive title function, what does it do and how do you use it?

WordPress uses a function named the_archive_title(), usually at the top of the archive templates in your theme in order to dynamically generate a suitable title for the page. Since the function is used on many different types of pages, it generates a suitable title for each archive view.

The function itself is relatively simple and is a wrapper function for echoing get_the_archive_title(). You can view the code for the archive title function on Github.

It completes a series of if/else statements and then sets a title based on which type of archive view is being shown.

For example if the user is viewing a category archive page, the title will look like this:

Category: {Category Name}

The {Category Name} part in the example of above would be replaced with the name of the category archive being viewed. For example, if we are viewing the category archive page for the “General” category, the title would look like this:

Category: General

If the user is viewing an author archive page, the function generates a title like this:

Author: {Author Display Name}

The {Author Display Name} part in the example above gets replaced depending on which author archive page is being viewed. For example if this was my author archive page, it would display like this?

Author: Mark Wilkinson

You can use this function in your theme anywhere on an archive page. The wrapper function takes 2 parameters, $before and $after. This is to allow you to output some content before and after the title is output. This is perfect for opening and closing HTML tags, most likely a h1.

How do you edit or customise the output of the archive title in WordPress?

Often users want to remove the archive title prefix which displays on category archives and also on post type archive by default. The prefix is “Category:” on a category archive page and “Archives” on a post type archive page. More often that not, clients want to remove this archive title prefix.

Thanks to the extensibility of WordPress, making changes to the way in which the archive titles are output in WordPress is pretty straightforward with a simple piece of code. You can either add this code to your themes functions.php, or better still add it as part of a modifications plugin that you can activate on your site. This means if you change themes you won’t lose this feature.

Looking back at the get_the_archive_title() function again we can see that towards the end of that code, the generated title is passed through a WordPress filter like so:

return apply_filters( 'get_the_archive_title', $title, $original_title, $prefix );

This is great because it allows developers to change the output. Since it is passed through a filter, this means WordPress is passing the data (the title) to us to modify and then we can pass it back.

To do this we can create a simple function to make the necessary changes and hook this function into WordPress using the filter provided.

In this example we are changing the category archive titles to display in the following format:

View all posts in {Category Name}

In this example the {Category Name} part is again replaced with the name of the category archive being viewed.

If you are looking to target other archive page views you can use any of the conditional functions in WordPress in a similar way to is_category() in the example above.

Learn more about customising archive titles with filters

If you want to learn more about how to customise the WordPress archive titles using the WordPress filters available, then take a look at this video.

The Highrise Digital Archive Title Control plugin for WordPress

At Highrise Digital, we found that we were making some of the same edits on many of the website projects that we build.

Therefore to try and speed things up we decided to package these edits into a plugin that we could use on our client websites to give clients better control over the archive titles on their WordPress sites.

The Highrise Digital Archive Title Control plugin allows site authors and editors to control the archive titles for:

  • The blog home page which lists the site’s posts.
  • Category archives
  • Tag archivesAuthor archives – an option to enter an archive title appears on each users profile page
  • Post type archives – each post type which supports an archive as an option to enter the title listed under Settings > Reading in the WordPress admin
  • Author archives

Purchase the Archive Title Control plugin

The archive title control plugin for WordPress is an easy way to allow WordPress editors and authors to control the titles on archive pages from within the WordPress admin area.


Archive Title Control

Easily control archive titles in the WordPress admin for:

  • Categories
  • Tags
  • Custom taxonomies
  • Post type archives
  • Author archives
  • Blog home

About the author

Mark is the lead WordPress developer at Highrise Digital. He has been working with WordPress for over 15 years, way back to 2005. He focuses on back-end development, integrating the website build with WordPress so everything can be editable.