【函数】

<?php get_post_mime_type( $ID ) ?>

【用法】

<?php
$mime_type=get_post_mime_type( 36 );//假设id为36的文章是图片类型是“image/jpeg”
echo $mime_type;

//打印出image/jpeg
?>
修改记录
自2.0.0版本后

【源文件】

get_post_mime_type() 位于wp-includes/post.php中。

/**
 * 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.
 *
 * @since 2.0.0
 *
 * @param int $ID Optional. Post ID.
 * @return bool|string False on failure or returns the mime type
 */
function get_post_mime_type($ID = '') {
    $post = & get_post($ID);

    if ( is_object($post) )
        return $post->post_mime_type;//就是返回post_mime_type字段的值

    return false;
}