Displaying post type descriptions

Ever since post type creation became “public” in WordPress 3.0.0 in June 2010, users have been able to provide a description for their post type. However, for whatever reasons that the WordPress core team has, they have never provided an official way to retrieve that description value. Thankfully, the “get_post_type_object()” function provides that value for a provided post type. This allows us to create our own custom function that can be used to display the description value.

function pluginize_display_post_type_description( $post_type_slug = '' ) {
	$mytype = get_post_type_object( $post_type_slug );
	if ( ! empty( $mytype ) ) {
		echo $the_post_type->description;
	}
}

Using this function, which you can rename however you prefer, will return the description of whatever post type slug you provide it. This would be good to potentially use in your theme and specifically archives for any given post type you may want to provide more details for.

Updated Dec 12, 2022 9:09 PM