wordpress snippets

Remove the Word “Category” From Category Title

Last modified: January 13, 2020

Cloudways

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;

});

 

Show More

* This button will show the rest of the post and open up an offer from a vendor
Save 4 Later
Email liked links to yourself