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()) { ?
title
?php category_titles_change(); ?
/title
?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?