合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
[TOC] ## **wordpress文章函数:get_post_mime_type()** ### **函数说明** 按ID编号检索附件的mime类型。 该函数可用于任何文章类型,但更适用于附件类型。 * * * * * ### **函数用法** ~~~ <?php get_post_mime_type( $ID ) ?> ~~~ * * * * * ### **参数说明** $ID (整数)(可选)文章ID 默认值:” * * * * * ### **示例** ~~~ <?php $mime_type=get_post_mime_type( 36 );//假设id为36的文章是图片类型是“image/jpeg” echo $mime_type; ~~~ * * * * * ### **返回值** 返回的值 (布尔型|字符) 返回mime类型,出错时则返回False。 * * * * * ### **源文件** ~~~ 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; } ~~~ * * * * *