get_header_textcolor()WP 2.1.0

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

No Hooks.

Return

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

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.

Code of get_header_textcolor() WP 6.0

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