WordPress at Your Fingertips

get_post_mime_type() WP 1.0

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.

Uses: get_post()

No Hooks.


String|false. The mime type on success, false on failure.


get_post_mime_type( $post );
Post ID or post object.
Default: global $post


Since 2.0.0 Introduced.

Code of get_post_mime_type() WP 5.8

function get_post_mime_type( $post = null ) {
	$post = get_post( $post );

	if ( is_object( $post ) ) {
		return $post->post_mime_type;

	return false;

From tag: post

More from category: Attachments (Media files)

No comments
    Log In