the_archive_title()WP 4.1.0

Display the archive page title, based on the type of page (tag, term, category, date).

Used for returning/displaying the title of the current term, date, post type, post format, or author archive.

No Hooks.


null. Nothing (null).


the_archive_title( $before, $after );
Content to prepend to the title.
Default: ''
Content to append to the title.
Default: ''



#1 Print the header for the archive pages

Suppose we have a template file index.php, handles all the archive pages and we need to specify each of them a different header, for example:

  • If a category, then: "Category: optimization".
  • If tag, then: "Tag: coding".
  • If archive by year, then: "Year: 2104".

Before WP 4.1 we did this with a combination of conditions if ... else ... and conditional tags, but now we can use just one line:

<h1><?php the_archive_title() ?></h1>

#2 Remove the "Category:", "Tag:" prefix on the archives page

Since WP 5.5 we can do it using get_the_archive_title_prefix hook:

// remove “Category:”, “Tag:”, “Author:” ... archive title
add_filter( 'get_the_archive_title_prefix', '__return_empty_string' );

Prior WP 5.5, use the following hack:

// Removes "Category: ", "Tag: " etc. from the archive header
add_filter( 'get_the_archive_title', function( $title ){
	return preg_replace( '~^[^:]+: ~', '', $title );
} );

#3 More examples

See here: get_the_archive_title().



Since 4.1.0 Introduced.

the_archive_title() code WP 6.4.3

function the_archive_title( $before = '', $after = '' ) {
	$title = get_the_archive_title();

	if ( ! empty( $title ) ) {
		echo $before . $title . $after;