【发布时间】:2011-03-04 10:41:19
【问题描述】:
我正在为 wordpress 编写插件,但在处理图像时遇到了问题。如果我在 wp-content/plugins/my-plugin/ 中有我的插件,并且在其中有一个文件夹 images/test.png - 我如何在我的代码中引用该图像?我不想把图片放到主题中,因为当其他用户来获取我的插件时,图片将无法正常工作!
所以我的结构是
myplugin/plugin.php (which includes several files...)
myplugin/pluginstyle.css
myplugin/includes/page.php
myplugin/images/test.png
我的样式表工作得很好,但是当我尝试使用图像作为元素的背景时,它不起作用。
如何在插件中引用图片?
page.php 的测试输出
<div class="test"><p>hello</p></div>
css
.test { background: url(../images/test.png) repeat-x; }
我哪里错了?有没有我应该使用的方法? 感谢您的帮助!
【问题讨论】:
-
CSS 是外部的,还是嵌入在 HTML 中的?
-
见下面的帖子。我使用 wp_head 动作钩子调用 CSS。所以它是外部的,不是嵌入到我认为的 html 中?
标签: css stylesheet wordpress