函数文档

the_header_image_tag()

💡 云策文档标注

概述

the_header_image_tag() 函数用于显示自定义标题图像的 HTML 图像标记。它基于 get_header_image_tag() 生成输出,适用于 WordPress 主题开发。

关键要点

  • 函数功能:输出自定义标题图像的图像标记,简化前端显示。
  • 参数:接受一个可选的 $attr 数组参数,用于设置图像属性,如 class、id 等,默认值为空数组。
  • 依赖关系:内部调用 get_header_image_tag() 函数来创建图像标记。
  • 版本历史:自 WordPress 4.4.0 版本引入。

代码示例

the_header_image_tag( array( 'class' => 'header-img' ) );

注意事项

用户贡献笔记中提到,可以通过传递数组参数来添加自定义类名,例如为图像添加 'header-img' 类,以方便样式控制。


📄 原文内容

Displays the image markup for a custom header image.

Parameters

$attrarrayoptional
Attributes for the image markup.

Default:array()

Source

function the_header_image_tag( $attr = array() ) {
	echo get_header_image_tag( $attr );
}

Changelog

Version Description
4.4.0 Introduced.

User Contributed Notes