Get a list of WordPress post types that support a feature

Need to be able to fetch a list of post types that support a specific feature, like thumbnails, excerpts, etc?  This nifty little function will let you do just that:

/**
 * Get a list of post types that support a specific feature.
 * 
 * @param $feature
 * @return array
 */
function get_post_types_that_support( $feature ) {
	global $_wp_post_type_features;
	$post_types = array_keys(
		wp_filter_object_list( $_wp_post_type_features, array( $feature => true ) )
	);
	return $post_types;
}

About

Micah is an Atlanta-based WordPress developer who is committed to continuously improving his understanding of WordPress and sharing his insights with the greater WordPress community.

Leave a Reply

Your email address will not be published. Required fields are marked *