Function: get_attached_media

get_attached_media( string $type, integer | WP_Post $post )

Retrieves media attached to the passed post.

Parameters

Name Type(s) Default Value Description
$type string

Mime type.

$post integer | WP_Post

Optional. Post ID or WP_Post object. Default is global $post.

Returns

array

Found attachments.

WordPress Developer Newsletter

Stay on top of the latest WordPress API changes, developer tool updates, security alerts and more.