Looks like this is two questions: how to get all the children that are audio, and how to get all the children that aren’t audio.
1) The post_mime_type
parameter of get_children
can actually take a wildcard, so you could use:
$children = get_children(array(
'post_parent' => $post->ID,
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type => 'audio/%'
));
2) You can’t do a mime-type exclusion using get_children
, so you’re better off just filtering the whole list to exclude them that way. I think you’ve got the right idea, just use something like this to exclude all the different kinds of audio:
if ( ! strstr($mime, 'audio/') ) { // ...etc
Related Posts:
- How to update the title of audio file through its attachment metadata
- Add audio attachment link to RSS
- Display Audio Attachment URL
- Display audio file in audio.php
- Get video attachment ID and display length
- How To Retrieve An Image Attachment’s Alt Text?
- How to get attachment file name not attachment URL
- Programmatically adding images to the media library with wp_generate_attachment_metadata randomly fails
- How to cleanly delete attachment but retain original file?
- Replace audio/video enclosure with player?
- Trying to hide buttons from Attachment window
- Uploading Multiple Attachments From Front-End With A Description
- Validate alt text for attachments?
- Get all posts (of any post type) an attachment is used in
- Give attachments an archive page
- Can I attach a document (eg: PDF) but have a JPEG as a thumbnail?
- Retrieving a custom link on an attachment
- How can I display custom fields value from attachment media?
- how to test for attached image
- WP REST – video and audio players
- Unable to upload specific .zip file type via frontend in WordPress 4.0
- Add_Filter example for wp_get_attachment_link
- Can i hide the attachments from media which I uploaded from front end?
- attachment url rewrite
- Automatically delete attachments and posts [closed]
- How to delete orphan attachments?
- Get the title and URL of the attachment parent post
- Confused with attachment mimetype order
- Disable edit media attachments?
- query attachment images … if no attachments -> get attachments of parent page?
- Replacing with(out) regex link to attachment by links to files
- Post Auto Draft Issue
- Getting attachment images is cloning some of them
- rename attachments based on parent-post-title on upload
- Rename attachments during upload no matter what filetype
- Link all WordPress images size
- post_author for wp_insert_attachment
- Post Via Email – How to send Attachments with it (e.g. PDF File or JPEG Image)?
- 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)
- Ordering of gallery images without using shortcode in theme
- Adding width and height to wp_get_attachment_image_src
- custom admin thumbnail for videos, not getting post’s id?
- Audio file’s length (duration) is missing from Attachment Details in Media Library [closed]
- Image Gallery Numbers for 3.5
- Control attachments menu order with jQuery Sortable
- How to delete a custom file from upload directory when deleting its post
- Media library quick/inline edit
- Check what attached image size is used
- Query to only return the 2 newest post attachments (images)?
- Clean up images, delete unused image sizes attached to a post type
- Custom image sizes add to metadata
- What is the best way to store thumbnails for a non-image attachment?
- Change default selection for “Embed or Link”?
- What will happen if I delete all my attachment type posts from database?
- Weird string offset errors when displaying post attachments
- the_time() returning wrong date/time (way in the future)
- How to: Retrieve an attachment image from post and output it
- Links to my uploads went crazy
- hide attached images of a post
- How to add a caption to an image attachment in a file list?
- Echo list attachment size in post
- How do I intercept and modify the functionality of wp_get_attachment_image()?
- Undoing define( ‘UPLOADS’, ”.’files’ ); to repoint to “wp-content/uploads” folder
- Upload image and assign it’s id to post
- Possible to add “Even/Odd Classes” to image attachments via wp_get_attachment_image?
- Can’t sort get_posts by post_mime_type
- How to get thumbnail from post attachment in this loop
- How can I rewrite old attachment URLs?
- How to list “invisible” Auto Drafts?
- How to add media from front-end to an existing post and edit file title
- How can I customize the link when an attached image is clicked?
- Add a word to the first // wp_get_attachment_url // as the subdomain name
- How is it possible that a gallery doesn’t have attachment ids?
- Media Library Mess After FTP … /uploads
- Media item permalink goes to source file instead of attachment.php
- wp_delete_attachment doesn’t delete image files / doesn’t work
- Removing images deleted from uploads folder, from Media Library
- how to add data in my custom theme from WP-Admin Panel
- Display setting ‘size’ not available in image settings modal
- Attachment file display link text
- Removing delete permanently button in uploading files media
- Retrieve ONLY mp3s and set a variable for use in a playlist called by single.php template?
- missing attachment are showing as 404
- Insert attachments from front end form
- How do I add Facebook OpenGraph meta tags for attachments in the header for a custom theme?
- Add link to attachment for old posts
- Drupal 6 to WordPress migration – media attachments
- Retreive tags from attached post for media on page
- Move caption in on attachment page
- How to fetch all videos in custom page which uploaded in wp-admin (Media) in wordpress
- get_image_tag filter not working
- Get Video Attachment to post
- Change attachment inside the_content using filters
- Bulk delete media by year
- Count images in post then add class if just one
- One audio attachment, with two possible interchangeable extensions
- No attachments on contact form 7
- wp_mail attachment not working in wordpress