
Inside those folders are multiple files that I want to display on frontend.

Here is how I managed to get those directories and the pdf files inside them.
$upload_dir = wp_upload_dir(); $folder = $upload_dir['basedir']; // THIS IS TO GET ALL FOLDERS FOUND ON THE DIRECTORY //In this example, I only want to get the folders under /wp-content/uploads/pdfs $issues = scandir( $folder.'/pdfs' ); //check if the folders are showing echo '<pre>'; print_r($issues); echo '</pre>';

//THIS IS TO GET ALL THE FILES ON THE FOLDERS I HAVE FETCHED ABOVE foreach( $issues as $issue ){ $articles = scandir( $folder.'/pdfs/'.$issue ); //check if the files are showing echo '<pre>'; print_r($articles ); echo '</pre>'; foreach( $articles as $article ){ echo home_url( 'wp-content/uploads/pdfs/'.$issue.'/'.$article ).'<br>'; } }
