Remove WordPress archive title prefix

On almost every website that I create, the archives don’t need to be titled as “archives”, because it’s self-explanatory that the page is an archive. So I quite often remove the “Archive:” prefix of all archive pages, including custom post types.

Just paste this code to your functions.php:

// Remove anything that looks like an archive title prefix ("Archive:", "Foo:", "Bar:").
add_filter('get_the_archive_title', function ($title) {
    return preg_replace('/^\w+: /', '', $title);

Thanks to Quinn Comendant, who posted a comprehensive solution to this problem on StackExchange.