WordPress at a glance

get_the_archive_description() WP 4.1.0

Retrieves the description of the post type, category, tag, term, or author archive page.

This function is intended to be used on taxonomy (categories and tags), posts and authors archive pages.

On author archive page, the description is retrieved from his Biographical Info field; on taxonomies archive pages — from description field; on posts types archive pages — with get_the_post_type_description() function.

If you want to display the description, use a wrapper for this function: the_archive_description().

Is the basis for: the_archive_description()
Hooks from the function
Return

String. Archive description.

Usage

get_the_archive_description();

Examples

#1 Display the description of the archive page (except date archive pages)

Suppose we need to display the description for categories, tags or taxonomies archive pages:

$description = get_the_archive_description();

if ( $description ) {
	echo "The description: $description";
}

But it's better to use the_archive_description() for such purposes if you need just display the description. In this case we could use a $before parameter to prepend the description with our own text.

Notes

  • See: term_description()

Changelog

Since 4.1.0 Introduced.
Since 4.7.0 Added support for author archives.
Since 4.9.0 Added support for post type archives.

Code of get the archive description: wp-includes/general-template.php WP 5.2.2

<?php
function get_the_archive_description() {
	if ( is_author() ) {
		$description = get_the_author_meta( 'description' );
	} elseif ( is_post_type_archive() ) {
		$description = get_the_post_type_description();
	} else {
		$description = term_description();
	}

	/**
	 * Filters the archive description.
	 *
	 * @since 4.1.0
	 *
	 * @param string $description Archive description to be displayed.
	 */
	return apply_filters( 'get_the_archive_description', $description );
}

Related Functions

From tag: Description (of post term)

More from category: Archives

No comments
    Hello, !     Log In . Register