Remove Category: Prefix From WordPress Archive Titles

WordPress puts a prefix in front of archive titles: “Category: News”, “Tag: Tips”, “Author: Jane”, “Year: 2024”, “Archives: Books”. This snippet removes the Category: prefix and all the others from WordPress archive titles, so the page shows just “News”.

It uses the filter WordPress added for exactly this in version 5.5, so the title itself, its translation and its markup stay as WordPress builds them. A small config lets you keep the prefix on chosen archive types, for example on author pages.

The snippet

<?php
/**
 * Remove the "Category:", "Tag:", "Author:" … prefix from WordPress archive titles.
 */

// ===== Config =====
function dpc_archive_title_prefix_config() {
	$config = array(
		// Archive types that KEEP their prefix: 'category', 'tag', 'author', 'date', 'post_type', 'taxonomy'.
		// Empty array = remove the prefix everywhere.
		'keep' => array(),
	);
	// ===== End of config =====

	return (array) apply_filters( 'dpc_archive_title_prefix_config', $config );
}

add_filter( 'get_the_archive_title_prefix', 'dpc_archive_title_prefix' );

function dpc_archive_title_prefix( $prefix ) {
	$config = dpc_archive_title_prefix_config();
	$keep   = (array) ( $config['keep'] ?? array() );

	if ( ! $keep ) {
		return '';
	}

	$current = array(
		'category'  => is_category(),
		'tag'       => is_tag(),
		'author'    => is_author(),
		'date'      => is_date(),
		'post_type' => is_post_type_archive(),
		'taxonomy'  => is_tax(),
	);

	foreach ( $keep as $type ) {
		if ( ! empty( $current[ $type ] ) ) {
			return $prefix;
		}
	}

	return '';
}

How it works

  • get_the_archive_title() builds the title and the prefix separately and passes the prefix through the get_the_archive_title_prefix filter. An empty prefix leaves only the title, with no extra <span> around it.
  • With keep empty, the callback returns '' for every archive: categories, tags, authors, dates, post type archives and custom taxonomies.
  • With types listed in keep, the callback checks the current page with is_category(), is_author(), is_date() and the other conditional tags, and returns the original prefix only there.
  • Nothing is rebuilt by hand. Older versions of this snippet recreated each title with single_cat_title(), get_the_author() and friends, and printed the author name without escaping. Here WordPress still produces the title, and the get_the_archive_title filter still receives the original title for other code.

Add it with Scripts Organizer

Scripts Organizer ships this snippet in its One-Click Import library as Remove Prefix From Archive Titles. To add it by hand, 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, edit the config and publish. Leave Action/Hook empty.

The filter only does something on archive pages, but Everywhere keeps the setup simple and also covers archive titles loaded by blocks and page builders.

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

Customise it

  • Keep “Author:” on author pages: 'keep' => array( 'author' ).
  • Keep the prefix on date archives, where “2024” alone can be unclear: add 'date'.
  • Keys: category, tag, author, date, post_type, taxonomy. taxonomy covers custom taxonomies, such as WooCommerce product categories.
  • Change the setting from other code with the dpc_archive_title_prefix_config filter.

Gotchas

  • Themes that print their own archive heading without get_the_archive_title() or the_archive_title() are not affected.
  • In block themes the Query Title block has its own Show archive type in title toggle. Turning it off does the same for that block, without code.
  • The blog posts page is not an archive in WordPress terms, so its title has no prefix to remove.

The older version of this post replaced the whole title for each archive type, missed date archives and printed the author name unescaped. This version only removes the prefix and adds the option to keep it per archive type.

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.