在WordPress中使用纯PHP代码,我在获取glob()
生成图像源。
<div class="carousel-inner" role="listbox" style="height=600px; width=1000px;">
<?php
$directory = "http://geocaa.com/wp-content/themes/Booting/img/services/";
$images = glob($directory . "*.png");
foreach($images as $image)
{
echo \'<div class="dynamic item">\';
echo \' <img src="\'.$image.\'" alt="...">\';
echo \' </div>\';
}
?>
</div>
正如你所看到的,我试图对$directory
像"http://geocaa.com/wp-content/themes/Booting/img/services/";
而且我已经在这两个帖子上进行了调查 [Post 1 &;Post 2 ] 关于同样的问题,但那里的解决方案仍然不适合我!这个get_theme_root()
除了get_template_directory()
返回更像
$images = glob(get_template_directory().$directory . "*.png");
/home/vcbb/public\\u html/wp-content/themes/geocaa/img/services/img。巴布亚新几内亚对图像src无效
我也试过了get_template_directory_uri()
但仍然得到空数组