get_header_textcolor()
Retrieves the custom header text color in 3- or 6-digit hexadecimal form.
Uses: get_theme_mod()
No Hooks.
Return
String
. Header text color in 3- or 6-digit hexadecimal form (minus the hash symbol).
Usage
get_header_textcolor();
Examples
#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
#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() get header textcolor code WP 6.6.2
function get_header_textcolor() { return get_theme_mod( 'header_textcolor', get_theme_support( 'custom-header', 'default-text-color' ) ); }