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
}
Related Posts:
- How To Retrieve An Image Attachment’s Alt Text?
- getting attachement images src and add classes
- Validate alt text for attachments?
- Applying automatic link class to images embedded to posts
- get post attachments of a particular size
- Change image link: wp_get_attachment_link
- Making images from single.php pointing to an attachment .php template
- wp_get_attachment_image_src always returns false
- Exact image sizes
- Get the size (size in Kb or MB) of an featured image?
- query attachment images … if no attachments -> get attachments of parent page?
- Edit default image attachment size
- Change code to display image attachment page
- Attachment 0×0 size error [closed]
- Add image attachment to post via coding?
- Removing width and height attributes from wp-get-attachment
- Get post attachment images dimension and use in embed code
- use wp_get_attachment_image() to show attachments
- Adding width and height to wp_get_attachment_image_src
- Get the bare URL for an attachment
- Display attachment resolution size
- How to check if there is image title, caption, description?
- How to remove attachments size attribute [duplicate]
- How to redirect ‘file url’ to ‘post url’ i.e. in attachment.php
- Check what attached image size is used
- How do I get all attachments that are used in the current post, not just the children?
- Clean up images, delete unused image sizes attached to a post type
- Get title of post image is attached to
- Correct attachment size
- Post Gallery list attachments except the one used as post thumbnail
- Get image attachment to a post outside the loop?
- How do I intercept and modify the functionality of wp_get_attachment_image()?
- Unable to get wp_get_attachment_url to show
- Get Attachment Image Class by attachment id
- Possible to add “Even/Odd Classes” to image attachments via wp_get_attachment_image?
- changing the default picture size link url
- Get an image from the media library. Struggling with the code?
- How to view exact image dimensions of a media in Admin view?
- Filter not applied to all image sizes
- wp_get_attachment_image_src calling wrong location
- Get attachment URL from attachment Link in WordPress
- Display setting ‘size’ not available in image settings modal
- Hide Image Container if No Image Attachments
- Incomplete attachment page
- How to retrieve “custom url” from image attachment in wordpress
- Retreive tags from attached post for media on page
- list of attachments: wp_get_attachment_link works, wp_get_attachment_image does not
- What is the most efficient way to retrieve a group of image URL’s from different attachment ID’s of a specific crop size?
- get_image_tag filter not working
- Change attachment inside the_content using filters
- How to get attachment file name not attachment URL
- Trying to hide buttons from Attachment window
- Uploading Multiple Attachments From Front-End With A Description
- Count the number of images uploded on the website
- Can I attach a document (eg: PDF) but have a JPEG as a thumbnail?
- How to remove images from showing in a post with the_content()?
- How to display a shortcode caption somewhere other than the_content
- Conditional Statement – check if post has an attachment image
- Allowing post attachments without allowing to insert in text
- attachment url rewrite
- Display Single Attachment Image file size, uploaded date, resolution, file-name etc in Sidebar
- Converting a simple plugin to be placed inside of functions.php
- Get the title and URL of the attachment parent post
- Confused with attachment mimetype order
- get_attachment_id() only get id of first attached image after post update
- rename attachments based on parent-post-title on upload
- Rename attachments during upload no matter what filetype
- Link all WordPress images size
- Custom page template to display all image attachments
- Displaying Post Attachment(s) at Top of single.php
- Detach an image from a page using php
- Get the path of the first attached media (single.php)
- custom admin thumbnail for videos, not getting post’s id?
- Image Gallery Numbers for 3.5
- How can I attach hotlinked images in posts/pages within the same server?
- How to delete a custom file from upload directory when deleting its post
- Auto delete attachments that are older than x days
- Replacing the content of an image attachment using API
- What is the best way to store thumbnails for a non-image attachment?
- Add attachment for all images in post
- get_post_meta not working on category.php
- What will happen if I delete all my attachment type posts from database?
- How do you get the full size url of an attachment image
- Weird string offset errors when displaying post attachments
- WordPress Creates Unused (Unregistered) Image Sizes
- hide attached images of a post
- How to add a caption to an image attachment in a file list?
- Can’t sort get_posts by post_mime_type
- How to get post id of first child of the same post type?
- How to list “invisible” Auto Drafts?
- How to add media from front-end to an existing post and edit file title
- How to echo images Urls from a wordpress post, that are relally in the post
- Media item permalink goes to source file instead of attachment.php
- Attachment file display link text
- Get video attachment ID and display length
- Open image size links in a page instead of direct image link
- Create a custom attachment thumbnail for quick page load
- How can I hide previous_image_link() on first attachment page?
- Move caption in on attachment page
- wp_mail attachment not working in wordpress