WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to retreive media image directly into the library... Something like get_media ('all') and it return a array with image url, caption, description etc etc..

share|improve this question
up vote 2 down vote accepted

Here you go:

function get_media_all_wpa14177(){
    $args = array(
        'post_type' => 'attachment',
        'post_mime_type' =>'image',
        'post_status' => 'inherit',
        'posts_per_page' => -1,
    $query_images = new WP_Query( $args );
    $images = array();
    foreach ( $query_images->posts as $image) {
        $images[]= $image->guid;
    return $images;


$Images = get_media_all_wpa14177();
share|improve this answer
The guid is not guaranteed to always point to an existing file, it's better to return the attachment post IDs and then use the specific functions, like wp_get_attachment_metadata. – Jan Fabry Apr 7 '11 at 18:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.