get_the_post_type_description()WP 4.9.0

Получает описание текущей архивной страницы типа записи.

Описание указывается при регистрации типа записи в параметре description, см. функцию register_post_type().

Функцию нужно использовать на архивной странице типа записи, см. условный тег is_post_type_archive().

Работает на основе: get_post_type_object()
1 раз — 0.000249 сек (быстро) | 50000 раз — 0.30 сек (очень быстро) | PHP 7.1.5, WP 4.9
Хуки из функции

Возвращает

Строку. Описание архивной страницы типа записи.

Использование

get_the_post_type_description();

Примеры

0

#1 Выведем на экран описание архива типа записей

echo get_the_post_type_description();

Список изменений

С версии 4.9.0 Введена.

Код get_the_post_type_description() WP 6.5.2

function get_the_post_type_description() {
	$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 = '';
	}

	/**
	 * Filters the description for a post type archive.
	 *
	 * @since 4.9.0
	 *
	 * @param string       $description   The post type description.
	 * @param WP_Post_Type $post_type_obj The post type object.
	 */
	return apply_filters( 'get_the_post_type_description', $description, $post_type_obj );
}