get_the_archive_title

Retrieve the archive title based on the queried object.

Description

(string) get_the_archive_title(); 

Returns (string)

Archive title.


Usage

  1. if ( !function_exists( 'get_the_archive_title' ) ) { 
  2. require_once ABSPATH . WPINC . '/general-template.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = get_the_archive_title(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/general-template.php  
  1. function get_the_archive_title() { 
  2. if ( is_category() ) { 
  3. /** translators: Category archive title. 1: Category name */ 
  4. $title = sprintf( __( 'Category: %s' ), single_cat_title( '', false ) ); 
  5. } elseif ( is_tag() ) { 
  6. /** translators: Tag archive title. 1: Tag name */ 
  7. $title = sprintf( __( 'Tag: %s' ), single_tag_title( '', false ) ); 
  8. } elseif ( is_author() ) { 
  9. /** translators: Author archive title. 1: Author name */ 
  10. $title = sprintf( __( 'Author: %s' ), '<span class="vcard">' . get_the_author() . '</span>' ); 
  11. } elseif ( is_year() ) { 
  12. /** translators: Yearly archive title. 1: Year */ 
  13. $title = sprintf( __( 'Year: %s' ), get_the_date( _x( 'Y', 'yearly archives date format' ) ) ); 
  14. } elseif ( is_month() ) { 
  15. /** translators: Monthly archive title. 1: Month name and year */ 
  16. $title = sprintf( __( 'Month: %s' ), get_the_date( _x( 'F Y', 'monthly archives date format' ) ) ); 
  17. } elseif ( is_day() ) { 
  18. /** translators: Daily archive title. 1: Date */ 
  19. $title = sprintf( __( 'Day: %s' ), get_the_date( _x( 'F j, Y', 'daily archives date format' ) ) ); 
  20. } elseif ( is_tax( 'post_format' ) ) { 
  21. if ( is_tax( 'post_format', 'post-format-aside' ) ) { 
  22. $title = _x( 'Asides', 'post format archive title' ); 
  23. } elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) { 
  24. $title = _x( 'Galleries', 'post format archive title' ); 
  25. } elseif ( is_tax( 'post_format', 'post-format-image' ) ) { 
  26. $title = _x( 'Images', 'post format archive title' ); 
  27. } elseif ( is_tax( 'post_format', 'post-format-video' ) ) { 
  28. $title = _x( 'Videos', 'post format archive title' ); 
  29. } elseif ( is_tax( 'post_format', 'post-format-quote' ) ) { 
  30. $title = _x( 'Quotes', 'post format archive title' ); 
  31. } elseif ( is_tax( 'post_format', 'post-format-link' ) ) { 
  32. $title = _x( 'Links', 'post format archive title' ); 
  33. } elseif ( is_tax( 'post_format', 'post-format-status' ) ) { 
  34. $title = _x( 'Statuses', 'post format archive title' ); 
  35. } elseif ( is_tax( 'post_format', 'post-format-audio' ) ) { 
  36. $title = _x( 'Audio', 'post format archive title' ); 
  37. } elseif ( is_tax( 'post_format', 'post-format-chat' ) ) { 
  38. $title = _x( 'Chats', 'post format archive title' ); 
  39. } elseif ( is_post_type_archive() ) { 
  40. /** translators: Post type archive title. 1: Post type name */ 
  41. $title = sprintf( __( 'Archives: %s' ), post_type_archive_title( '', false ) ); 
  42. } elseif ( is_tax() ) { 
  43. $tax = get_taxonomy( get_queried_object()->taxonomy ); 
  44. /** translators: Taxonomy term archive title. 1: Taxonomy singular name, 2: Current taxonomy term */ 
  45. $title = sprintf( __( '%1$s: %2$s' ), $tax->labels->singular_name, single_term_title( '', false ) ); 
  46. } else { 
  47. $title = __( 'Archives' ); 
  48.  
  49. /** 
  50. * Filters the archive title. 
  51. * @since 4.1.0 
  52. * @param string $title Archive title to be displayed. 
  53. */