When you are building a custom WordPress theme or fine-tuning a child theme, you likely use the the_archive_title() function to display the title on your category, tag, and author pages. By default, WordPress prepends these titles with a prefix like "Category:", "Tag:", or "Author:". While this is helpful for clarity in the backend, it often disrupts the design and user experience of a modern front-end website.
From an SEO and UX perspective, having "Category: Travel Tips" as your H1 instead of just "Travel Tips" can be redundant. Fortunately, WordPress provides several ways to strip these prefixes away and keep your titles clean and professional. In this guide, you will learn the most efficient methods to remove these prefixes using hooks, filters, and direct template modifications.
The Modern Solution: Using the Prefix Filter (WP 5.5+)
If you are running a modern version of WordPress (version 5.5 or higher), there is a dedicated hook designed specifically for this purpose. Instead of filtering the entire title string, you can target just the prefix itself. This is the cleanest and most recommended method for most developers.
By using the get_the_archive_title_prefix filter, you can instruct WordPress to return an empty string for the prefix while leaving the actual title intact. You can add the following code to your theme's functions.php file:
/**
* Remove the prefix from archive titles (e.g., Category:, Tag:, Author:)
*/
add_filter('get_the_archive_title_prefix', '__return_empty_string');
This simple one-liner uses the built-in WordPress helper function __return_empty_string to effectively hide the prefix globally across all archive types. It is efficient, lightweight, and preserves the core functionality of your theme.
The Comprehensive Approach: Filtering the Entire Title
Sometimes, you might want more granular control over how titles are displayed. For example, you might want to remove the prefix for categories but keep it for custom taxonomies, or wrap the author's name in specific HTML for schema markup. In these cases, filtering the entire get_the_archive_title output is the way to go.
Here is a robust function you can add to your functions.php to handle various archive types individually:
add_filter('get_the_archive_title', function ($title) {
if (is_category()) {
// Returns only the category name
$title = single_cat_title('', false);
} elseif (is_tag()) {
// Returns only the tag name
$title = single_tag_title('', false);
} elseif (is_author()) {
// Returns the author name wrapped in a span for styling
$title = '<span class="vcard">' . get_the_author() . '</span>';
} elseif (is_tax()) {
// For custom taxonomies
$title = sprintf(__('%1$s'), single_term_title('', false));
} elseif (is_post_type_archive()) {
// For Custom Post Type archives
$title = post_type_archive_title('', false);
}
return $title;
});
Why Use This Method?
This approach is highly flexible. If you decide later that you want Custom Post Type archives to say "Our Projects: [Name]" while keeping categories clean, you can easily modify the logic within the elseif blocks. It gives you total programmatic control over the string output.
Direct Template Tag Replacements
If you prefer not to use filters in your functions.php file and would rather modify your template files directly (like archive.php, category.php, or tag.php), you can replace the generic the_archive_title() function with more specific template tags.
Instead of this:
<?php the_archive_title( '<h1 class="page-title">', '</h1>' ); ?>
You can use specific tags that do not include prefixes by default:
For Category Templates
Use single_cat_title() to display only the name of the current category:
echo '<h1 class="page-title">' . single_cat_title( '', false ) . '</h1>';
For Custom Post Type Archives
If you are building a custom archive template for a CPT and want to output just the title without the word "Archive," use this function:
post_type_archive_title();
The String Manipulation Shortcut
While not the most elegant solution, some developers prefer a quick string replacement directly in the template. This can be useful if you are working on a legacy site where you don't want to risk global filter changes. You can use PHP's str_replace to strip the unwanted text from the returned title.
<h1><?php echo str_replace("Category: ", "", get_the_archive_title()); ?></h1>
Note: This method is generally discouraged because it is language-dependent. If your site is translated into multiple languages (e.g., "Catégorie:" in French), this hardcoded string replacement will fail. Use the filter methods mentioned above for better compatibility and localization support.
Why Cleaner Archive Titles Matter for SEO
Search engines like Google place significant weight on the <h1> tag of a page. When your archive page title is "Category: High-Performance Laptops," the most important keywords are pushed further to the right. By removing the prefix, your primary keyword ("High-Performance Laptops") becomes the prominent focus of the heading.
Additionally, cleaner titles improve the Click-Through Rate (CTR) when these pages appear in search results or are shared on social media. Users are more likely to click on a link that looks like a curated topic page rather than a technical WordPress archive list.
Frequently Asked Questions
Does removing the prefix affect my breadcrumbs?
Usually, no. Most breadcrumb plugins (like Yoast SEO or Rank Math) use their own internal logic to generate breadcrumb trails. However, if your breadcrumb plugin pulls specifically from get_the_archive_title, the filters you applied will carry over. Always check your breadcrumb settings after applying these changes.
Will these changes disappear when I update WordPress?
As long as you add these filters to a Child Theme's functions.php file or a site-specific plugin, your changes will remain intact through WordPress core updates. Never modify the functions.php of a parent theme, as those changes will be overwritten.
Can I remove the prefix for only one specific category?
Yes! You can add conditional logic to the filter. For example, to only remove the prefix for a category with the slug 'news', you would use:
add_filter('get_the_archive_title', function ($title) {
if (is_category('news')) {
return single_cat_title('', false);
}
return $title;
});
Wrapping Up
Cleaning up your WordPress archive titles is a small change that makes a big difference in the professional appearance of your site. For most modern projects, the get_the_archive_title_prefix filter is the most efficient way to achieve this. If you need more control over specific archive types, the comprehensive get_the_archive_title filter provides the flexibility you need.
By following these steps, you ensure that your users see clean, relevant headings, and your SEO remains optimized with keyword-focused H1 tags.