Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save eirichmond/21bab5465c85db48ab302e29dcb55d52 to your computer and use it in GitHub Desktop.
Save eirichmond/21bab5465c85db48ab302e29dcb55d52 to your computer and use it in GitHub Desktop.
<?php
/* a couple of filters to remove elements from titles */
add_filter( 'get_the_archive_title', 'wptv_remove_title_elements', 10, 1);
function wptv_remove_title_elements($title) {
if ( is_category() ) {
$title = single_cat_title( '', false );
}
return $title;
}
/* if you want to remove elements from other archive pages use the other wp conditionals */
add_filter( 'get_the_archive_title', 'wptv_remove_title_elements_example_two', 10, 1);
function wptv_remove_title_elements_example_two($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>' ;
}
return $title;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment