Replace category titles


I want to display different titles in category archives than the category title.

I have created a function with if statements for this purpose:

function category_titles_change() {
    if (is_category('name1')) { ?>  
        new title 1
    <?php }
    elseif (is_category('name2')) { ?>  
        new title 2
    <?php }
    elseif (is_category('name3')) { ?>  
        new title 3
    <?php }

How can I use this to change the <title></title> shown in the <head></head>

I have tried this:

function head_category_titles_change() {    
 if (is_category()) { ?> 
<?php category_titles_change(); ?> 
<?php }}
add_action( 'wp_head', 'head_category_titles_change' );

But this ads a second <title> to the <head> in addition to the default title.
How can I replace the default Title in Category archives with my desired titles?

IXN 2 months 0 Answers 11 views 0

Leave an answer