函数文档

get_header_textcolor()

💡 云策文档标注

概述

get_header_textcolor() 函数用于检索自定义标题文本颜色,返回3位或6位十六进制格式的字符串(不含井号)。该函数通过 get_theme_mod() 获取主题修改值,并支持默认值回退。

关键要点

  • 返回值为字符串类型,表示标题文本颜色,格式为3位或6位十六进制(如 fff 或 ffffff),不包含 # 符号。
  • 函数内部调用 get_theme_mod('header_textcolor', get_theme_support('custom-header', 'default-text-color')),优先从主题修改中获取颜色,若无设置则使用默认值。
  • 相关函数包括 get_theme_support() 和 get_theme_mod(),用于获取主题支持和修改值。
  • 该函数自 WordPress 2.1.0 版本引入,常用于自定义标题处理。

代码示例

$header_text_color = get_header_textcolor();
echo "The color of the text inside the header is #". $header_text_color . ".";

📄 原文内容

Retrieves the custom header text color in 3- or 6-digit hexadecimal form.

Return

string Header text color in 3- or 6-digit hexadecimal form (minus the hash symbol).

Source

function get_header_textcolor() {
	return get_theme_mod( 'header_textcolor', get_theme_support( 'custom-header', 'default-text-color' ) );
}

Changelog

Version Description
2.1.0 Introduced.

User Contributed Notes