- This topic is empty.
February 4, 2013 at 9:17 pm #42481
Hi guys and gals!
I’m using some PHP code to dynamically pull images from a directory on a static site with no problems.
When I try to alter the code to pull images from a directory in a WordPress installation, it fails.
$dirArray = $entryName;
$indexCount = count($dirArray);
The end echo statement is just so I can see whether it’s populating the array or not. There is another loop statement to display the images, which I believe is fine. I just can’t get my head around why this doesn’t seem to be working.
Is anyone able to help?February 4, 2013 at 11:23 pm #123373__Participant
What is the value of `$tempDir`?
Does your call to `opendir()` succeed?
You might also be interested in PHP’s [`glob()`](http://php.net/glob) function.February 6, 2013 at 1:28 am #123533
Thanks for responding @traq.
Umm… the first line is a $tempDir allocation, so that should be fine.
I’m guessing it doesn’t succeed, as the array count is always 0. If I change $tempDir to a set path in a static site, the whole thing works fine. I think its the mixing of the template_url and relative path into a variable and then calling that variable that’s causing the issue, but I’m not certain.
Had played around with glob() in the past, but once I got this working with opendir(), I moved on. Might have to go back and revisit.
Any other ideas?February 6, 2013 at 8:32 am #123559
As it turns out, for anyone who is stuck with a similar issue:
Replacing get_bloginfo(‘template_url’) with TEMPLATEPATH fixes the issue.February 6, 2013 at 10:17 am #123565__Participant
> the first line is a $tempDir allocation, so that should be fine.
“should be,” sure. But you need to check. That function might be failing – you have no way to know unless you check.
> Replacing get_bloginfo(‘template_url’) with TEMPLATEPATH fixes the issue.
As a side note, you should avoid using URLs to access stuff on your own host. There’s no reason to open your front door, walk around the house, and come in through the back door just to get from the living room to your kitchen, right?
- The forum ‘Back End’ is closed to new topics and replies.