Home > database >  WordPress: how to change the category page title to just the category name?
WordPress: how to change the category page title to just the category name?

Time:10-07

I need to change the page title of enter image description here

This is what I see when I check the coding of the page:

enter image description here

Please help me change the page name to News instead of Category: News

CodePudding user response:

Place this code in your functions.php file

function change_category_page_title( $title ) {
    $title_arr = explode(':', $title);
    if ( count($title_arr) > 0 ){
        if(array_key_exists(1, $title_arr)) {
            return $title_arr[1];
        }
    }
    return $title;
}
add_filter( 'pre_get_document_title', 'change_category_page_title', 9999 );

CodePudding user response:

Try with this CSS

.category-news h1.page-title span {
   font-size: 42px;
} 
.category-news h1.page-title {
    font-size: 0;
}

Hope it works

  • Related