Make WordPress Core

Ticket #38545: ADDED FEATURE REQUEST - Example - get_the_archive_title.php

File ADDED FEATURE REQUEST - Example - get_the_archive_title.php, 2.9 KB (added by Kaira, 8 years ago)

This is get_the_archive_title() with my added feature request

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