From f6b5c794bf946bc7a1fc5524dc46234c4f4c6521 Mon Sep 17 00:00:00 2001 From: Drew Jaynes Date: Sat, 1 Jul 2017 05:15:46 +0000 Subject: [PATCH] General: Add support for the post type archive description to `get_the_archive_description()`, and thereby also `the_archive_description()`. Props henrywright. Fixes #38487. Built from https://develop.svn.wordpress.org/trunk@40976 git-svn-id: http://core.svn.wordpress.org/trunk@40826 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/general-template.php | 18 +++++++++++++++++- wp-includes/version.php | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 3b186757f1..e4516328bf 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -1540,18 +1540,34 @@ function the_archive_description( $before = '', $after = '' ) { } /** - * Retrieve category, tag, term, or author description. + * Retrieves the description for an author, post type, or term archive. * * @since 4.1.0 * @since 4.7.0 Added support for author archives. + * @since 4.9.0 Added support for post type archives. * * @see term_description() * * @return string Archive description. */ function get_the_archive_description() { + $description = ''; + if ( is_author() ) { $description = get_the_author_meta( 'description' ); + } elseif ( is_post_type_archive() ) { + $post_type = get_query_var( 'post_type' ); + + if ( is_array( $post_type ) ) { + $post_type = reset( $post_type ); + } + + $post_type_obj = get_post_type_object( $post_type ); + + // Check if a description is set. + if ( isset( $post_type_obj->description ) ) { + $description = $post_type_obj->description; + } } else { $description = term_description(); } diff --git a/wp-includes/version.php b/wp-includes/version.php index 1bbfda34dd..4ddf431a87 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.9-alpha-40975'; +$wp_version = '4.9-alpha-40976'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.