Make WordPress Core


Ignore:
Timestamp:
07/01/2017 05:14:18 AM (7 years ago)
Author:
DrewAPicture
Message:

General: Add support for the post type archive description to get_the_archive_description(), and thereby also the_archive_description().

Props henrywright.
Fixes #38487.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/general-template.php

    r40955 r40976  
    15411541
    15421542/**
    1543  * Retrieve category, tag, term, or author description.
     1543 * Retrieves the description for an author, post type, or term archive.
    15441544 *
    15451545 * @since 4.1.0
    15461546 * @since 4.7.0 Added support for author archives.
     1547 * @since 4.9.0 Added support for post type archives.
    15471548 *
    15481549 * @see term_description()
     
    15511552 */
    15521553function get_the_archive_description() {
     1554    $description = '';
     1555
    15531556    if ( is_author() ) {
    15541557        $description = get_the_author_meta( 'description' );
     1558    } elseif ( is_post_type_archive() ) {
     1559        $post_type = get_query_var( 'post_type' );
     1560
     1561        if ( is_array( $post_type ) ) {
     1562            $post_type = reset( $post_type );
     1563        }
     1564
     1565        $post_type_obj = get_post_type_object( $post_type );
     1566
     1567        // Check if a description is set.
     1568        if ( isset( $post_type_obj->description ) ) {
     1569            $description = $post_type_obj->description;
     1570        }
    15551571    } else {
    15561572        $description = term_description();
Note: See TracChangeset for help on using the changeset viewer.