Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yellowberri-snippets/0f6575340868a78ec083 to your computer and use it in GitHub Desktop.
Save yellowberri-snippets/0f6575340868a78ec083 to your computer and use it in GitHub Desktop.
PHP: WP: Return Heading for Archive Pages : ybArchiveTitle()
// Return term of Archive Page.
function ybArchiveTitle() {
$archiveTitle = "";
if ( is_category() ) {
$archiveTitle = single_cat_title('', FALSE);
}
elseif ( is_tag() ) {
$archiveTitle = single_tag_title('', FALSE);
}
elseif ( is_author() ) {
global $post;
$author_id = $post->post_author;
$archiveTitle = get_the_author_meta('display_name', $author_id);
} elseif ( is_day() ) {
$archiveTitle = get_the_time('l, F j, Y');
} elseif ( is_month() ) {
$archiveTitle = get_the_time('F Y');
} elseif (is_year()) {
$archiveTitle = get_the_time('Y');
}
return $archiveTitle;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment