Created
July 13, 2021 19:47
-
-
Save jorpdesigns/439e45a1bd3525bb2cfb386ff9624682 to your computer and use it in GitHub Desktop.
Snippet to remove prefixes from archive titles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'get_the_archive_title', function ($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_tax() ) { //for custom post types | |
$title = sprintf( __( '%1$s' ), single_term_title( '', false ) ); | |
} elseif (is_post_type_archive()) { | |
$title = post_type_archive_title( '', false ); | |
} | |
return $title; | |
}); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment