Replies: 0
In a previous topic I lamented that a renamed category base did not reflect the change in category archive page headings. @alchymyth replied with a perfect solution….though a solution that, twenty months later, I cannot successfully modify.
Michael’s first if block was fine, but I’d like to customize further by assigning a unique label to each category archive.
This code will not work. I’ve tried various other work-arounds like iterating the category array into a string. I just can’t seem to figure this out. PHP is not my forte; I’m a Perl guy (yes, I know PHP morphed out of Perl, but I find PHP inordinately more obtuse than Perl).
function use_category_base_in_archive_title( $title )
{if ( is_category() && get_option('category_base') )
$title = str_replace( 'Category:', ucfirst( get_option('category_base') ) . ':', $title );
elseif ( is_category() && preg_match("/English/i", get_the_category()) )
$title = str_replace( 'Category:', 'Language:', $title );
elseif ( is_category() && preg_match("/Spanish|Español/i", get_the_category()) )
$title = str_replace( 'Category:', 'Idioma:', $title );
elseif ( is_category() && preg_match("/French|Français/i", get_the_category()) )
$title = str_replace( 'Category:', 'Langue:', $title );
elseif ( is_category() && preg_match("/Latine?/i", get_the_category()) )
$title = str_replace( 'Category:', 'Lingua:', $title );
return $title;
}
add_filter( 'get_the_archive_title', 'use_category_base_in_archive_title' );