Archive Titles

Have you ever wondered how to remove taxonomic default titles from your archive titles? Tax-a-what? You heard me! Here: check it out.

You see that page is looking pretty good except for that funky 'Category:' part, right? How can we get rid of that? I'll show you. It's not too tough.

First, we check out archive.php -- the majority of themes use archive.php to handle the templating of category archives.

See in the code above where the tag 'the_archive_title' is used? That means that whatever type of archive you are visiting -- author, category, tag, etc. -- is going to show the title of that archive and wrap it with an h3 tag that has a class applied to it for style.

You might be wondering how this gets us any closer to our answer. Well, we really just needed to know what kind of template tag was being used to generate that title. Now we know and we can write a quick function in functions.php to help out.

add_filter( 'get_the_archive_title', function ($title) {

    if ( is_category() ) {

            $title = single_cat_title( '', false );

        } 

    return $title;

});

That's one way to solve our problem. And here's what we get.

Cool, right? Doesn't that look better?