• 欢迎来到本站,本站主要做程序员相关技术、博客、笔记,如果喜欢本网站那么赶紧使用Ctrl+D 收藏吧!
  • 如果有任何疑问,可以在下方文章下方留下你的评论~

get_post_mime_type() function in wordpress and example

视频教程 9个月前 (09-27) 3次浏览 0个评论

Description

<?php get_post_mime_type( $ID ) ?>

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.

example

Suppose that the article with ID 36 is an image, and the type is "image / jpeg"

<?php
$mime_type=get_post_mime_type( 36 );
echo $mime_type; //print image/jpeg

Source

get post mime_ Type () is located in 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;

    return false;
}

中国笔友, 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:get_post_mime_type() function in wordpress and example
喜欢 (0)
发表我的评论
取消评论
表情 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址