How about using the single_cat_title()
function regardless of what type of archive it is? For example:
function get_the_subtitle() {
if( is_archive() ) {
$subtitle="Blog posts for ";
}
if( is_category() || is_tag() ) {
$subtitle .= single_cat_title( '', false );
}
if( is_author() ) {
$curauth = ( get_query_var( 'author_name' ) ) ?
get_user_by( 'slug', get_query_var( 'author_name' ) ) :
get_userdata( get_query_var( 'author' ) );
// you can set this to many things, see the get_userdata() docs for a list
$subtitle .= $curauth->user_nicename;
}
if( is_date() ) {
$month = get_query_var('monthnum')
$day = get_query_var('day')
$year = get_query_var('year')
$string = '';
$string .= ( !empty( $day ) ) ? $day : '';
$string .= ( !empty( $string ) ) ? "https://wordpress.stackexchange.com/" : '';
$string .= ( !empty( $month ) ) ? $month : '';
$string .= ( !empty( $string ) ) ? "https://wordpress.stackexchange.com/" : '';
$string .= ( !empty( $year ) ) ? $year : '';
$subtitle .= $string;
}
if( !empty( $subtitle ) ) {
return $subtitle;
} else {
return false;
}
}