我正在创建一个插件,我想加载一个文件夹的内容。文件夹位于themes
文件夹
我似乎无法指向插件中的文件夹<如果.php
文件也位于themes
文件夹:
$path = dirname(realpath(__FILE__)).\'/images/{foldername}\';
这就是我所拥有的:
$path = dirname(realpath(__FILE__)).\'/images/brands_icons\';
if ($handle = opendir($path)) {
$bgis = array();
while ($bgis[] = readdir($handle));
sort($bgis);
closedir($handle);
}
$blacklist = array(\'\',\'.\',\'..\');
$search = \'.png\';
$replace = \'\';
foreach ($bgis as $bgi) {
if (!in_array($bgi, $blacklist)) {
echo \'<img src="\'.get_bloginfo(\'template_directory\').\'/images/{foldername}/\'.$bgi .\'" />\';
}
}
我得到的警告是:
Warning: opendir(http://www.website.com/themes/{themename}/images/{foldername})
[function.opendir]: failed to open dir: not implemented in .../wp-content/plugins/{pluginname}/
custom-meta-box-template.php on line 208
---------------------------------
更新:
我已用以下方法修复了它:
$path = ( ABSPATH .\'/wp-content/themes/{themename}/images/{foldername}\' );
我不知道这样做是否正确。因此,希望您能提供一些反馈/想法!
M