I need to make a gallery template that shows all the images in a subdirectory of the uploads folder using php but I cannot access it.

This would be the structure:


Im trying to get all this images and count how many of them I have with this code but its not working:

$src = wp_upload_dir()["baseurl"]."/anyfolder/anotherfolder";

$total_images = count(glob($src,GLOB_BRACE));

I can only get the images number in the uploads dir but cannot access the subdirectories

Thanks in advice

Read more here: How can I get images from a subdirectory of uploads folder


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: