V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
seaflower
V2EX  ›  PHP

新手问个很基础的问题, wordpress 页眉 PHP 文件中的 html 不能调用图片是怎么回事?

  •  
  •   seaflower · 2020-04-23 10:26:04 +08:00 · 2065 次点击
    这是一个创建于 1465 天前的主题,其中的信息可能已经有所发展或是发生改变。
    需求是这样的,要自定义页眉 php 文件中,把文件全部替换成 html 代码,但是代码中<img src="../XXX/xxx.jpg">标签调用图片无法显示,src 中用互联网图片链接则正常显示,请问各位大佬这个怎么解决呀
    bzj
        1
    bzj  
       2020-04-23 13:53:14 +08:00
    请学习绝对路径跟相对路径
    youngs
        2
    youngs  
       2020-04-23 16:23:13 +08:00
    使用 <?php bloginfo('template_directory'); ?> 这种方式输出当前模板路径
    比如你得路径改成
    <img src="<?php bloginfo('template_directory'); ?>/XXX/xxx.jpg">
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2828 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 02:50 · PVG 10:50 · LAX 19:50 · JFK 22:50
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.