WordPress php glob();不工作?
我在WordPress中创建了一个函数,我希望获取给定目录中的所有图像,我正在使用PHP glob函数,由于某些原因,我无法使其工作,glob()函数在WordPress中被禁用了吗 不起作用的代码WordPress php glob();不工作?,php,wordpress,glob,Php,Wordpress,Glob,我在WordPress中创建了一个函数,我希望获取给定目录中的所有图像,我正在使用PHP glob函数,由于某些原因,我无法使其工作,glob()函数在WordPress中被禁用了吗 不起作用的代码 function getAccreditaionLogos(){ define('ACCREDPATH', get_stylesheet_directory_uri() . '/img/accreditations/'); $images = glob(ACCREDPATH .
function getAccreditaionLogos(){
define('ACCREDPATH', get_stylesheet_directory_uri() . '/img/accreditations/');
$images = glob(ACCREDPATH . '*.png');
foreach($images as $key => $img):
$get_icons = '<li><img src="'.$img.'" /></li>';
echo $get_icons;
endforeach;
}
函数getAuthentitaionLogos(){
定义('accreditPath',get_stylesheet_directory_uri()。/img/accreditions/');
$images=glob(accredadpath.'*.png');
foreach($key=>$img的图像):
$get_icons='';
echo$get_图标;
endforeach;
}
函数
get\u stylesheet\u directory\u uri()
为您提供一个web url(http://…)
. 必须使用绝对系统路径。您可以使用get\u theme\u root()
函数来获得它
您的函数应该如下所示:
function getAccreditaionLogos(){
define('ACCREDPATH', get_theme_root() . '/img/accreditations/');
$images = glob(ACCREDPATH . '*.png');
foreach($images as $key => $img):
$get_icons = '<li><img src="'.$img.'" /></li>';
echo $get_icons;
endforeach;
}
函数getAuthentitaionLogos(){
定义('accreditPath',get_theme_root()。/img/accreditions/');
$images=glob(accredadpath.'*.png');
foreach($key=>$img的图像):
$get_icons='';
echo$get_图标;
endforeach;
}
更多。什么显示了
var\u dump(get\u stylesheet\u directory\u uri())
,所有赋值之后ACCREDPATH
中有什么?很好,我使用了错误的声明。