get_the_post_type_description

函数
get_the_post_type_description ( No parameters )
返回值
  • (string) The post type description.
定义位置
相关方法
get_the_author_descriptionget_the_archive_descriptionget_file_descriptionget_the_post_navigationget_the_posts_pagination
引入
4.9.0
弃用
-

get_the_post_type_description: 该函数返回当前文章类型或作为参数传递给它的文章类型的描述。

检索文章类型档案的描述。

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 );
}

常见问题

FAQs
查看更多 >