Make WordPress Core

Ticket #38545: get_the_archive_title().php

File get_the_archive_title().php, 2.9 KB (added by Kaira, 10 years ago)

The original get_the_archive_title() in /wp-includes/general-template.php

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