douzhizao0270 2017-02-16 23:18
浏览 38

访问WordPress文件夹之外的图像文件夹

Can a folder outside of the WordPress directory but still on the server be accessed through WordPress?

I can successfully access files inside my theme folder but I am trying to access a folder full of images outside of the WordPress folder.

What changes need to be made?

$home_directory = site_url();
$home_uri       = home_url();

$vendorLogo = $home_uri. '/clientimages/directory/logo' . $vendor->acctno . '.png';

if ( file_exists( $home_directory . $vendorLogo ) ) {
  echo '<br>';
  printf( '<img class="vendorImage" src="%s"/>', esc_url( $home_uri . $vendorLogo ) );
}
  • 写回答

2条回答 默认 最新

  • drhanjuw56233 2017-02-16 23:41
    关注

    Are you on a multisite? If not then you should be able to access it with a complete URL like http://www.example.com which would be the root of your domain and you probably can't get past that unless it's your own server. You can also try relative URL's like ../ which will get you one directory higher than where your at. Most Wordpress sites get installed in a subdirectory one level below the root and the path to the themes directory is something like this: /installation subdirectory/wp-content/themes/theme directory. If you use a path that starts with a forward slash the Wordpress will add the home_url for you.

    So if your trying to get another logo image then you can try http://yourdomain.com/ then add the path to when your image resides.

    You can also load images with your media library and in that case you can upload them from your computer thus giving you access to the rest of the world. You can get the url to those images from the media library.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分