I've searched the web for help on this, I found similar questions, but not exactly what I'm looking for. Hopefully someone can help.

The following code is in my theme's archive.php file:

<header class="entry-archive-header">
    the_archive_title( '<h1 class="entry-title entry-archive-title">', '</h1>' );
    the_archive_description( '<div class="category-description">', '</div>' );

the_archive_title section of the code is causing the following text to appear on my WP page:

  • Archives: Projects

It's formatted a certain way where the text is large and bold. It looks really nice however, I want to change the value of this. I want it to display the following instead:

  • Viewing All Offices

I've literally have tried to do everything. I'm a bit of a noob at WP, but this is my first time doing this. I could not figure how how to change the text value to that.

If someone can please help me out, that would be great. Looking for the most cleanest and secure solution.


I've always found that the best way to learn about how WP works and how you can modify it is to search the Codex at https://codex.wordpress.org/

For example, first I find the Codex page for the_archive_title() and there I see that it's a wrapper for get_the_archive_title() and there, looking at the source code, I see that at the end of the function the result is returned through a filter also called get_the_archive_title.

So, now I know I can affect the output using that filter, I can write a little function to add to my theme's functions.php file to hook into that:

function change_my_title( $title ){
    if ( $title == "Archives: Projects" ) $title = "Viewing All Offices";
    return $title;
add_filter( "get_the_archive_title", "change_my_title" );

Hope that helps

| improve this answer | |
  • One note: several plugins such as Yoast SEO, has a similar (but limited) feature and can overwrite this function & hook you put into your functions.php. It happened with me and i didn't get what i'm doing wrong with such a small function., then half n hour later i got enlightened on this problem. ;) – Viktor Borítás May 2 at 18:56
  • 1
    @ViktorBorítás This is true, and worth pointing out, but the way to get around that is to add a priority to your filter so it runs after any others, such as add_filter( "get_the_archive_title", "change_my_title", 100 ); (the higher the number, the later it runs). – Peter HvD May 4 at 11:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.