Hi,
I have the following code i'm using to display all of my image files from a directory. This code works perferctly everywhere i try. Except when i try within a wordpress theme:
//path to directory to scan
$directory = "http://mywebsite.com/imgs/";
//get all image files with a .jpg extension.
$images = glob($directory . "*.jpg");
//print each file name
foreach($images as $image)
{
echo $image;
}
I've tried modifying the code to display the directory dynamically, like so:
$blogtheme = get_bloginfo('template_directory');
$directory = $blogtheme . "/imgs/";
and i can echo the $directory fine, but it doesn't return any of the files. If i echo $images i only get wordpress display the word 'Array' on my page.
I think the problem is to do with this line, possibly the 'glob' function not working in wordpress:
$images = glob($directory . "*.jpg");
If anyone could provide any help, it would be much appreciated.
Thanks!