【问题标题】:Image source path changing on different pages不同页面上的图像源路径更改
【发布时间】:2016-04-20 00:53:56
【问题描述】:

我正在使用 Genesis,并且我有一个 functions.php,我使用页脚的钩子在其中插入了图像。

我使用了一个小部件将图像插入到标题中。

在首页查看时图片正常显示,但切换页面时图片不显示。

进一步调查得出结论,wordpress 正在寻找路径源错误的文件。

就是首页中的路径源——wp-content\themes\childTheme-Almog\images\linkedin.png

wordpress 正在寻找它。

但是,在另一个名为“X”的页面上,wordpress 正在寻找相同的图像,如下所示: \wordpress\x\wp-content\themes\childTheme-Almog\images\linkedin.png

如您所知,它将页面名称作为文件夹添加到路径中,这是不应该的,因为图像不存在。

有没有办法让 wordpress 像在主页上一样查找图片?

这是我的图片在我的functions.php中的实现方式:

<div class="d_footer">
        <ul id="list_left">
            <li class="foot" id="ft_text1"><img src="wp-content\themes\childTheme-Almog\images\phone.png" alt="phone">
                <span style="color: #969697">|</span><span style="margin-left:30px;"></span><img src="wp-content\themes\childTheme-Almog\images\envelope.png" alt="envelope"></li>
            <li class="foot" id="ft_text2"></li>

        </ul>
    <ul class="foot" id="list_right">
        <li id="ft_text3"><img src="\wp-content\themes\childTheme-Almog\images\linkedin.png" alt="linkedin" align="left">Almog's linkedin profile</li>
        <li id="ft_text4"></li>
    </ul>
</div>

【问题讨论】:

    标签: php html wordpress genesis


    【解决方案1】:

    你真的应该使用 Wordpress 的 get_stylesheet_directory_uri 变量来缓解这样的路径问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-07
      • 2019-11-07
      • 2013-01-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-23
      相关资源
      最近更新 更多