我最近安装了一个 WP,将 /css/ 插入到一些背景图像的 url 中。当它应该是 /theme/images/image.png 时,我在浏览器检查器中得到“/theme/css/images/images.png”。我什至在 css 文件夹中没有任何文件夹;图像文件夹位于同一级别。
我不知道这是从哪里来的。除了硬编码之外,我已经尝试了所有可能的 url(images/、./images 和 ../images),但我应该这样做。
这是一个自定义主题,它是白板主题的子主题。
有什么想法吗?
Paths specified inside a CSS style sheet are relative to that style sheet.
So most likely, you have a CSS file with
background-image: url("images/images.png")
style URLs in it.
The solution might be to change the URLs to
background-image: url("../images/images.png")
主题是使用get_bloginfo('template_url')还是类似的东西get_bloginfo('stylesheet_directory')?如果背景图像是在 PHP 中设置的,这可能是问题所在。更多信息:http ://codex.wordpress.org/Function_Reference/get_bloginfo
如果你在 CSS 中设置它,你可以尝试像 Pekka 建议的相对 URL,或者像根相对 URL/wp-content/themes/[theme name]/