【发布时间】:2017-12-19 16:37:09
【问题描述】:
在 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 [Post 1 和Post 2 ] 进行了调查,但那里的解决方案仍然对我不起作用!
get_theme_root() 什么都不返回,但 get_template_directory() 返回的东西更像
$images = glob(get_template_directory().$directory . "*.png");
/home/vcbb/public_html/wp-content/themes/geocaa/img/services/img.png
对图片src没用
【问题讨论】:
标签: php wordpress wordpress-theming