0

I want to know how to get the folder in wordpress and get all the files from that folder in an array so i can use it as anchor tag to download it .. I'm trying to search on google but because i'm new so no luck for me today will any of you please help me? also want to save it if any new files i add then it have to automatically come to that place as new anchor any one can help me please? and also want to display them on wordpress admin dashboard

Huzail Jamil
  • 96
  • 1
  • 1
  • 13

1 Answers1

2

If you know the name of the directory, you could check PHP scandir()

Something like:

$directory = "/folder-name/";

$directory_array = scandir($directory);

print_r($directory_array);

This should return an indexed array containing images names.

Keep in mind that WordPress does not archive all files in a single folder, by default they are organized by year and month.

FrancescoCarlucci
  • 1,570
  • 12
  • 13