get_header_textcolor()WP 2.1.0

Gets the text color for the header (title). The color is set in the theme settings if this option is enabled in the theme.

Header color support is established through add_theme_support( 'custom-header' ), parameter default-text-color.

Use the function header_textcolor() when you need to output the result to the screen immediately.

No Hooks.

Returns

String. Color in HEX format without the hash (#), for example: cccccc or 333333.

Usage

get_header_textcolor();

Examples

0

#1 Get the color of the header text

This example takes the color of the header text that is set in themes settings, places it in the $header_text_color variable, and then displays it:

$header_text_color = get_header_textcolor();

echo "The color of the text inside the header is #{$header_text_color}.";
// get: The color of the text inside the header is #333333
0

#2 Using the function in the html style attribute of the <header> tag

<header style="<?= sprintf( 'color: #%s;', get_header_textcolor() ); ?>">

Changelog

Since 2.1.0 Introduced.

get_header_textcolor() code WP 6.9.1

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