Languages: English • Reference/get attached media 日本語 (Add your language)
Retrieve media attached to the passed post. Uses get_children().
<?php get_attached_media( $type, $post_id ) ?>
Get image attachment(s) to the current Post:
$media = get_attached_media( 'image' );
Get attachment(s) of mime-type 'audio' to the Post with an ID of 102:
$media = get_attached_media( 'audio', 102 );
get_attached_media() is located in wp-includes/media.php
.
Audio: wp_audio_shortcode(), wp_get_audio_extensions(), get_attached_media(), wp_embed_handler_audio(), wp_mediaelement_fallback(), wp_read_audio_metadata(), wp_add_id3_tag_data()
Video: wp_video_shortcode(), wp_get_video_extensions(), get_attached_media(), wp_embed_handler_video(), wp_mediaelement_fallback(), wp_read_video_metadata(), wp_add_id3_tag_data()