Reputation: 44353
hey guys, what do I misunderstand here?
$dir = get_bloginfo('template_url').'/images/headers/';
echo $dir;
//ouput: myblog.com/wp-content/themes/mytheme/images/headers
$dir = new DirectoryIterator(get_bloginfo('template_url').'/images/headers/');
echo $dir;
//output: nothing at all! blank page!
the console puts out a fatal_error:
[26-Apr-2011] PHP Fatal error: Uncaught exception 'RuntimeException' with message 'DirectoryIterator::__construct(http://myblog.com/wp-content/themes/mytheme/images/headers/) [directoryiterator.--construct]: failed to open dir: not implemented' in /Users/myname/htdocs/myblog.com/wp-content/themes/mytheme/inc/header-image.php:3 Stack trace:
0 /Users/myname/htdocs/myblog.com/wp-content/themes/mytheme/inc/header-image.php(3):
DirectoryIterator->__construct('http://oberperf...')
1 /Users/myname/htdocs/myblog.com/wp-content/themes/mytheme/header.php(69):
include('/Users/myname...')
2 /Users/myname/htdocs/myblog.com/wp-includes/theme.php(1112):
require_once('/Users/myname...')
3 /Users/myname/htdocs/myblog.com/wp-includes/theme.php(1088):
load_template('/Users/myname...', true)
4 /Users/myname/htdocs/myblog.com/wp-includes/general-template.php(34):
locate_template(Array, true)
5 /Users/myname in /Users/myname/htdocs/myblog.com/wp-content/themes/mytheme/inc/header-image.php
on line 3
any idea what goes wrong here?
Upvotes: 0
Views: 3221
Reputation: 4510
I'm pretty sure that the path must be absolute from the document root, not a URL.
Try get_template_directory()
instead:
$dir = new DirectoryIterator( get_template_directory() . '/images/headers/');
echo $dir;
Upvotes: 0
Reputation: 53581
Looks like you're passing a URL instead of a path:
DirectoryIterator->__construct('http://oberperf...')
You should pass the full local path name of the directory to the constructor.
Upvotes: 1