在WordPress中使用PHP glob()时遇到问题

在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>

如你所见, 我试图将$目录硬编码为” 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_html/wp-content/themes/geocaa/img/services/img.png

对图像src没用


#1


尝试这个:

$directory = "/img/services/";
$images = glob(get_template_directory().$directory . "*.png");
foreach($images as $image)
{
    echo '<div class="dynamic item">';
    echo ' <img src="'. str_replace(get_home_path(), get_home_url(), $image) .'" alt="...">';
    echo ' </div>';
}

来源:

https://www.srcmini02.com/65145.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_37328.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?