Tag Info

Hot answers tagged


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 ...


Here's how to check if the post has an attachment other than image (or other mime types): <?php $attachments = get_posts( array( 'post_type' => 'attachment', 'posts_per_page' => -1, 'post_parent' => $post->ID, 'exclude' => 'image' )); if ( $attachments ) { ?> ...

Only top voted, non community-wiki answers of a minimum length are eligible