I'm trying to get all of the images inside a specific sub-directory within the WordPress uploads directory, and then output all of those images.

$upload_dir = wp_upload_dir(); 

$logo_dir = ( $upload_dir['baseurl'] . '/logos/' );
echo $logo_dir . '-----<br />';
$images = glob( $logo_dir . "*.PNG" );
foreach( $images as $image ) {
    echo $image;

$logo_dir is outputting the correct directory. I'm not sure what I'm doing wrong with the foreach.

  • Are all of your images png files that have an uppercase .PNG extension?
    – Milo
    Commented Oct 11, 2015 at 1:17
  • @Milo Yes they are Commented Oct 11, 2015 at 1:19

1 Answer 1


$upload_dir['baseurl'] should be $upload_dir['basedir']. You want the server path, not the URL of the directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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