Skip to content

Instantly share code, notes, and snippets.

@dotherightthing
Last active August 15, 2019 12:16
Show Gist options
  • Save dotherightthing/0ea3dc2a588917e7a183a2b66f0f779e to your computer and use it in GitHub Desktop.
Save dotherightthing/0ea3dc2a588917e7a183a2b66f0f779e to your computer and use it in GitHub Desktop.
[Customise Archive H1] #wordpress

Customise Archive H1

Created: 2017.03.30

From Remove “Category:”, “Tag:”, “Author:” from the_archive_title

add_filter( 'get_the_archive_title', function ($title) {
  if ( is_category() ) {
    // Category_name
    $title = single_cat_title( '', false );
  } elseif ( is_tag() ) {
    // Category_name/Tag_name
    $category = get_the_category();
    $title = single_tag_title( $category[0]->name . '/', false );
  } elseif ( is_author() ) {
    $title = '<span class="vcard">' . get_the_author() . '</span>';
  }
  return $title;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment