How can I get images from a subdirectory of uploads folder

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:

wp_content/uploads/anyfolder/anotherfolder/my_images

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

Leave a Reply

Your email address will not be published. Required fields are marked *