Advertisement
Udoro

Remove 'Category' prefix

Apr 7th, 2021
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. add_filter( 'get_the_archive_title', 'my_theme_archive_title' );
  2. /**
  3. * Remove archive labels.
  4. *
  5. * @param string $title Current archive title to be displayed.
  6. * @return string Modified archive title to be displayed.
  7. */
  8. function my_theme_archive_title( $title ) {
  9. if ( is_category() ) {
  10. $title = single_cat_title( '', false );
  11. } elseif ( is_tag() ) {
  12. $title = single_tag_title( '', false );
  13. } elseif ( is_author() ) {
  14. $title = '<span class="vcard">' . get_the_author() . '</span>';
  15. } elseif ( is_post_type_archive() ) {
  16. $title = post_type_archive_title( '', false );
  17. } elseif ( is_tax() ) {
  18. $title = single_term_title( '', false );
  19. }
  20.  
  21. return $title;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement