I'm uploading some pdf files and .doc/docx files in a project. So, I'm inserting a link attachment file inside the loop and is working fine.
But I need to get a specific attribute: the mimetype.
So, I need to print the attachment url and mimetype, like this
Download file on http://domain.com/wp-content/...file.pdf File Type: pdf or application/pdf
Could someone help me with this?
By the way, I开发者_如何学编程´m using a custom theme and not the default wordpress theme.
Thanks a lot.
Flávio
There is a function for that
echo get_post_mime_type();
If you are indeed dealing with an attachment post type inside the loop, you should be able to access the post_mime_type:
global $post;
$mime_type = $post->post_mime_type;
global $post
may already be set, but if not, it is necessary in order to access the post data.
精彩评论