Remove the Archive Title Prefix in WordPress

WordPress archive titles start with a prefix: “Category: News”, “Tag: Recipes”, “Archives: Products”, “Author: Jane”. Most designs only want the name.

This one-line snippet removes the prefix from every WordPress archive title, in classic themes and in block themes.

The snippet

<?php
/**
 * Remove the "Category:", "Tag:", "Archives:" and similar prefixes from WordPress archive titles.
 */
add_filter( 'get_the_archive_title_prefix', '__return_empty_string' );

Add it with Scripts Organizer

In Scripts Organizer go to Code Blocks → Add New and give the block a name. Set Trigger location to Everywhere, tick PHP under Script location, paste the code into the PHP editor and publish. Leave Action/Hook empty. The filter only runs when a template asks for the archive title.

The same code also works unchanged in a small plugin or an mu-plugin.

How it works

  • get_the_archive_title() builds the title from a prefix and the name. Since WordPress 5.5 the prefix has its own filter, get_the_archive_title_prefix.
  • Returning an empty string from that filter makes WordPress return the plain name, without the <span> it normally wraps around it.
  • It works for every archive type: categories, tags, custom taxonomies, authors, dates and post type archives, in every language.
  • The earlier version split the title at : , which failed in languages that use other punctuation and depended on a screen-reader-text class. Its header also had a copied description about Oxygen fonts.

Variant: keep the prefix for screen readers

If you want the prefix hidden visually but still read out by screen readers, use this instead. It needs the screen-reader-text class, which most themes define.

<?php
/**
 * Hide the prefix visually but keep it for screen readers.
 * Needs the .screen-reader-text class, which most themes define.
 */
add_filter( 'get_the_archive_title_prefix', 'dpc_archive_title_prefix_screen_reader' );

function dpc_archive_title_prefix_screen_reader( $prefix ) {
	return '' === $prefix ? $prefix : '<span class="screen-reader-text">' . esc_html( $prefix ) . '</span>';
}

Gotchas

  • In block themes the Query Title block has a Show archive type in title toggle; you can switch it off per template without code. The snippet does the same for every template at once.
  • Themes that print their own heading (for example single_cat_title()) never had a prefix; this filter does not change them.
  • Only one archive type? See Remove “Category:” text in archive page title.

In the Scripts Organizer library Import it with one click from Scripts Organizer.

// newsletter

Three tested WordPress snippets a week

Blocks, security, performance, Tailwind, PHP and React. Copy, paste, ship. You’ll also get DPlugins product updates. No spam, and you can unsubscribe anytime.

// newsletter

Three tested WordPress snippets a week

Blocks, security, performance, Tailwind, PHP and React. Copy, paste, ship. You'll also get DPlugins product updates. No spam, and you can unsubscribe anytime.