How to remove “Category:” in title from category pages

By default, the category pages display title in format “Category: Category Title”. Showing “Category:” in title is worthless. To remove “Category:” from the title, you need to add some code to your WordPress theme. This post is about just to do that.

The problem of the category title

If you’re on the category page, it’s better to show only the category title (without the word “Category:”) or a breadcrumb like Home → Tour Places. That provide a clear information to users to show where they are. Keeping everything short and clear is always better.

How to remove “Category:” from category title

There are two options:

The first one is:

Open your archive.php and change
the_archive_title(); to single_cat_title();

Second option is also better, but it is base on themes. It works on 99% themes. Just look at that:

It’s easy to do that. Simply open the functions.php file in your WordPress theme and add the following code:

function prefix_category_title( $title ) {
    if ( is_category() ) {
        $title = single_cat_title( '', false );
    }
    return $title;
}
add_filter( 'get_the_archive_title', 'prefix_category_title' );

Now refresh your category pages and you will see “Category: ” is gone.

If the theme you’re using is a premium WordPress theme, you shouldn’t edit the functions.php file directly. Because you will loose all the edits when it’s updated. Instead of that, you should use a child theme to do any custom code.

After creating the child theme, put the code above in the functions.php file. It works similarly. And you never loose the change when the theme is updated.

Leave a Reply

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