background_image()
云策文档标注
概述
background_image() 是一个 WordPress 函数,用于直接输出自定义背景图像的路径。它基于 get_background_image() 函数实现,适用于主题开发中快速显示背景图像。
关键要点
- background_image() 函数直接输出背景图像的 URL 路径。
- 该函数内部调用 get_background_image() 来获取图像路径。
- 自 WordPress 3.0.0 版本引入,属于主题相关功能。
- 常用于主题模板文件中,以显示用户设置的自定义背景。
原文内容
Displays background image path.
Source
function background_image() {
echo get_background_image();
}
Changelog
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |
Skip to note 3 content
Codex
Display background image
<img src="" alt="" />Skip to note 4 content
rabmalin
Display background image
<img src="<?php background_image(); ?>" alt="" />