Title: displaying all attachments
Last modified: August 19, 2016

---

# displaying all attachments

 *  [animasola](https://wordpress.org/support/users/animasola/)
 * (@animasola)
 * [17 years ago](https://wordpress.org/support/topic/displaying-all-attachments/)
 * Which WordPress function displays or returns all post IDs of all media attachments
   within a certain blog? Or if there isn’t one, can anyone help me find a combination
   of functions which would do these? Ideally I want to retrieve all media attachments
   for a specific blog, so I’d want my argument/parameter to be the blog id and 
   the return to be an array/object of the details of the attachment or at least
   the attachment/post id.
 * Any piece of advice would be highly appreciated, thanks!

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [animasola](https://wordpress.org/support/users/animasola/)
 * (@animasola)
 * [17 years ago](https://wordpress.org/support/topic/displaying-all-attachments/#post-1077586)
 * Regarding the return, I meant an array of arrays/objects or attachment/post ids
 *  Thread Starter [animasola](https://wordpress.org/support/users/animasola/)
 * (@animasola)
 * [17 years ago](https://wordpress.org/support/topic/displaying-all-attachments/#post-1077587)
 * I seemed to have found it, it returns an array of attachment objects. Here it
   is for anyone whoever needs it as well:
 * Here is the function I created:
 *     ```
       global $wpdb;
       		if(!is_numeric($blog_id)) {
       			$blog_id = web_get_blog_id($blog_id);
       		}
       		$wpdb->set_blog_id($blog_id, 1);
   
       		$args = array(
       			'post_type' => 'attachment',
       			'post_mime_tyupe' => 'image'
       		);
   
       		if( !$attachments = get_children($args) ) {
       			return false;
       		} else {
       			return $attachments;
       		}
       ```
   
 *  [proximity2008](https://wordpress.org/support/users/proximity2008/)
 * (@proximity2008)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/displaying-all-attachments/#post-1077764)
 * Thanks for sharing – I’ve tried your function. What is the function web_get_blog_id()?
   WordPress complains it doesn’t exist.
 * Using WordPress 2.8

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘displaying all attachments’ is closed to new replies.

## Tags

 * [attachment](https://wordpress.org/support/topic-tag/attachment/)
 * [image](https://wordpress.org/support/topic-tag/image/)
 * [media](https://wordpress.org/support/topic-tag/media/)
 * [MySQL](https://wordpress.org/support/topic-tag/mysql/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [upload](https://wordpress.org/support/topic-tag/upload/)

 * 3 replies
 * 2 participants
 * Last reply from: [proximity2008](https://wordpress.org/support/users/proximity2008/)
 * Last activity: [16 years, 10 months ago](https://wordpress.org/support/topic/displaying-all-attachments/#post-1077764)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
