WordPress开发者和主题制作者的搜索引擎



get_post_mime_type ›

Since2.0.0
已弃用n/a
get_post_mime_type ( $post = null )
参数:
  • (int|WP_Post) $post Optional. Post ID or post object. Defaults to global $post.
    Required: No
    默认: null
返回:
  • (string|false) The mime type on success, false on failure.
定义在:
文档:

Retrieve the mime type of an attachment based on the ID.

This function can be used with any post type, but it makes more sense with attachments.



源码

function get_post_mime_type( $post = null ) {
	$post = get_post( $post );

	if ( is_object( $post ) ) {
		return $post->post_mime_type;
	}

	return false;
}