0

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.

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

1 Answer 1

3

$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 that you have read and understand our privacy policy and code of conduct.

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