久青草国产观看在线视频,在线观看欧美日女,777毛片,亚洲国产精品99久久久久久久

wordpress文章函數(shù):get_post_mime_type()

2016-09-02 wordpress函數(shù)
  • 文章介紹
  • 快速入門(mén)
  • 評(píng)價(jià)&建議

說(shuō)明

按ID編號(hào)檢索附件的mime類型。

該函數(shù)可用于任何文章類型,但更適用于附件類型。

用法

  1. <?php get_post_mime_type( $ID ) ?>  

參數(shù)

$ID

(整數(shù))(可選)文章ID

默認(rèn)值:”

返回的值

(布爾型|字符)

返回mime類型,出錯(cuò)時(shí)則返回False。

示例

  1. <?php  
  2. $mime_type=get_post_mime_type( 36 );//假設(shè)id為36的文章是圖片類型是“image/jpeg”  
  3. echo $mime_type;  
  4.   
  5. //打印出image/jpeg  
  6. ?>  

修改記錄

自2.0.0版本后

源文件

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

  1. /** 
  2.  * Retrieve the mime type of an attachment based on the ID. 
  3.  * 
  4.  * This function can be used with any post type, but it makes more sense with 
  5.  * attachments. 
  6.  * 
  7.  * @since 2.0.0 
  8.  * 
  9.  * @param int $ID Optional. Post ID. 
  10.  * @return bool|string False on failure or returns the mime type 
  11.  */  
  12. function get_post_mime_type($ID = '') {  
  13.     $post = & get_post($ID);  
  14.   
  15.     if ( is_object($post) )  
  16.         return $post->post_mime_type;//就是返回post_mime_type字段的值  
  17.   
  18.     return false;  
  19. }  
0 0

企業(yè)建站推薦正版商業(yè)主題,國(guó)內(nèi)專業(yè)團(tuán)隊(duì)開(kāi)發(fā),完善售后,是您不二選擇。

正版主題商店

主題貓WP建站,累計(jì)幫助1300+客戶成功建站,為站長(zhǎng)提供支持!

立刻開(kāi)啟你的建站之旅
QQ在線客服

服務(wù)熱線

wordpress建站咨詢