函数原型
get_post_mime_type( int|WP_Post $post = null ): string|false
函数描述
Retrieves the mime type of an attachment based on the ID.
是否弃用
未弃用
函数参数
-
$post
int|WP_Post
Optional - Post ID or post object. Defaults to global $post.
Default:
null
函数返回值
string|false The mime type on success, false on failure.
函数位置
File: wp-includes/post.php.
函数源码
function get_post_mime_type( $post = null ) {
$post = get_post( $post );
if ( is_object( $post ) ) {
return $post->post_mime_type;
}
return false;
}
源码链接
变更日志
| Version | Description |
|---|---|
| 2.0.0 | Introduced. |

