Embracing WordPress means diving deep into its features. One of the fundamental elements of posts is their category, but that’s not all. There are also tags and other kinds of taxonomies.
The default WordPress installation lets you leverage these, but taxonomies are labeled in the title as “Archive:”, or “Category:”, etc.
On the category page, the H1 title also includes the word Category, which, for most, is a big SEO no-no, leading many to opt out of using or displaying archive pages. But, there’s a workaround!
How to remove the word “Category:” from an archive or category subpage in WordPress?
I’ve got a simple trick for you. Just add the snippet below. How to add code to WordPress?
add_filter( 'get_the_archive_title', 'tr_archive_title' );
/**
Remove archive labels.
@param string $title Current archive title to be displayed.
@return string Modified archive title to be displayed.
*/
function tr_archive_title( $title ) {
if ( is_category() ) {
$title = single_cat_title( '', false );
} elseif ( is_tag() ) {
$title = single_tag_title( '', false );
} elseif ( is_author() ) {
$title = '' . get_the_author() . '';
} 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;
}
This code (snippet) will remove those unnecessary taxonomy pre-titles. As a result, your category page won’t have the “Category:” prefix. So, say goodbye to those pesky pre-title inserts and hello to cleaner, SEO-friendly titles! 🎉
Dzięki! To mi się napewno przyda bo strasznie mi się to nie podobało, ale nie miałem pomysłu jak zmienić nazwy kategorii, żeby było ładnie i SEO. 🙂
MIĘCHO