Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is there a PHP function that will return an array of all of my uploaded images? Or, failing that, how bout just my uploaded files?

The end goal is to display a slideshow on my homepage: have it rotate through each image, one at a time. Almost like an animated gif, in an infinite loop/cycle.

share|improve this question

1 Answer

up vote 2 down vote accepted

uploaded files are stored as attachment post type in WordPress. Use get_posts() and query for all attachments:

$args = array(
    'post_type' => 'attachment',
    'numberposts' => -1,
    'post_status' => null,
    'post_parent' => null ); 
$all_attachments = get_posts( $args );

EDIT - you can also set post_mime_type in get_posts to get all of type 'image/jpeg' for example.

share|improve this answer

Your Answer

 
discard

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.