wordpress snippets

Remove the Word “Category” From Category Title

Last modified: August 27, 2018

Normally on Archive/Category/Tag pages when using the title function the_archive_title we get a result that looks something like this: “Category: Category name”. This doesn’t look very professional. Here’s how you get rid of that annoying feature.

Add the following to your functions.php file:

add_filter( 'get_the_archive_title', function ($title) {

    if ( is_category() ) {
            $title = single_cat_title( '', false );
        } elseif ( is_tag() ) {
            $title = single_tag_title( '', false );
        } elseif ( is_author() ) {
            $title = '<span class="vcard">' . get_the_author() . '</span>' ;
        } 

    return $title;

});

 

Save 4 Later
Email these links to yourself