How to remove Archive:, Category: Etc. Pre-Title inserts in Archive Titles

Sumit Singh
Sumit Singh
16 May 2022

If you would like to get rid of the “Category:”“Tag:”“Author:”“Archives:” and “Other taxonomy name:” in the archive title, use this little function in Code Snippets

Default Archive title
After implemented below code

The Below can be added using a plugin like Code Scripts organizer or Code Snippets.

add_filter( 'get_the_archive_title', 'wpl_archive_title' );
/**
 * Remove archive labels.
 * @param  string $title Current archive title to be displayed.
 * @return string Modified archive title to be displayed.
 */
function wpl_archive_title( $title ) {
	if ( is_category() ) {
		$title = single_cat_title( '', false );
	} elseif ( is_tag() ) {
		$title = single_tag_title( '', false );
	} elseif ( is_author() ) {
		$title = '<span class="author">' . get_the_author() . '</span>';
	} elseif ( is_post_type_archive() ) {
		$title = post_type_archive_title( '', false );
	} elseif ( is_tax() ) {
		$title = single_term_title( '', false );
	} elseif ( is_home() ) {
		$title = single_post_title( '', false );
	}

	return $title;
}


        

Was this article helpful?

Tags

Categories

Never miss new post again

Subscribe and get list of new posts in your inbox

Click to Copy