Saturday , February 22 2025

How to remove “Category:” in the title of the article category

This issue is relevant if the title was added using the_archive_title();. To remove the extra phrase “Category:”, you need to use the hook:

add_filter( 'get_the_archive_title', 'lets_remove_name_category' );
function lets_remove_name_category( $title ){
	if ( is_category() ) {
		$title = single_cat_title( '', false );
	} elseif ( is_tag() ) {
		$title = single_tag_title( '', false );
	}
	return $title;
}

Add this code at the end of file functions.php of your theme.

This code allows you to remove any “Archives:”, “Category:”. It works for WooCommerce, which uses the same get_the_archive_title in the page-title:

add_filter( 'get_the_archive_title', function( $title ){
	return preg_replace('~^[^:]+: ~', '', $title );
});

About iryna

I'm Iryna, a web developer from Ukraine with a decade of experience solving complex technical challenges in the world of freelance. Throughout my career, I've worked on everything from troubleshooting server-side issues and optimizing website performance to enhancing user interfaces. On this blog, I share detailed solutions to the technical problems I’ve encountered and methods that have worked best for me. In addition to my technical expertise, I’m also passionate about digital drawing. I hope the tutorials and insights I provide here will help both fellow developers and creatives alike in their own projects.

Check Also

How to remove 404 //fonts.gstatic.com and //fonts.googleapis.com from WordPress head section

I tried solutions with functions that should remove from head and , but a very …

Leave a Reply

Your email address will not be published. Required fields are marked *