自定义wordpress主题:布局图像不显示 [英] custom wordpress theme: layout images not displaying

查看:123
本文介绍了自定义wordpress主题:布局图像不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个自定义的wordpress主题。因此,我的主题文件夹中包含以下文件/文件夹:

I'm building a custom wordpress theme.So I have my Theme folder with the following files/folders:

header.php
index.php
footer.php
style.css
/images
 picture-1.jpg

我的问题是我无法在index.php,header.php和footer中使用 img标记正确显示图像。 php:

My problem is that I can't display correctly images using img TAG either in index.php,header.php and footer.php:

[..]
<div class="module">
<h4>General info</h4>
<img src="images/picture-1.jpg"/>
[..]

如果style.css引用了图片,这些图片已经存在并可以正确显示:

Images are existing and are displaying correctly if referenced by style.css :

.banner{
  background-image:url(images/picture-1.jpg);
}

我想念东西吗?

感谢
Luca

thanks Luca

推荐答案

这是因为您的文件不在 /图片相对于您正在查看的页面,它们位于 wp-content / themes / [您的主题名称] /图片中。

It's because your files aren't in /images relative to the page you're viewing, they're in wp-content/themes/[yourthemename]/images.

您可以通过以下方法解决此问题:在站点的顶部将 base URL设置为站点根目录的URL,然后链接图像如上所示或通过使用类似这样的东西:

You can get round this by setting a base URL to the root of your site in the head section of your site and linking images as shown above or by using something like this:

< img src =<?php bloginfo('template_directory');?> ; /images/picture-1.jpg alt =替代文字 />

这篇关于自定义wordpress主题:布局图像不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆