Skip to content

Instantly share code, notes, and snippets.

@ThomasVitale
Last active February 15, 2018 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThomasVitale/6e3574278ef78f27fd5220dc894392fe to your computer and use it in GitHub Desktop.
Save ThomasVitale/6e3574278ef78f27fd5220dc894392fe to your computer and use it in GitHub Desktop.
Function to customise the title of WordPress archive pages
<?php
function thomas_archive_title( $title ) {
if ( is_category() ) {
$title = single_cat_title( '', false );
} elseif ( is_tag() ) {
$title = single_tag_title( '', false );
} elseif ( is_author() ) {
$title = '<span class="vcard">' . get_the_author() . '</span>';
} elseif ( is_post_type_archive() ) {
$title = post_type_archive_title( '', false );
} elseif ( is_tax() ) {
$title = single_term_title( '', false );
}
return $title;
}
add_filter( 'get_the_archive_title', 'thomas_archive_title' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment