Check if post has attachments (not image)

You can use the following within a loop:

$files = get_attached_media( $type, $post_id );

Just define the attachment MIME type on $type. Second parameter is optional. Example from the Codex page:

$media = get_attached_media( 'audio', 102 );

With the retrieved array, you can do something like:

if( $media ) {
   //Show the post attachments that are not images, but audio
}

Leave a Comment