I am having problems with add_theme_support('custom-header'); I can change the Header Text color but I can't hide my Header Text when I leave unchecked "Show header text with your image" inside admin panel (obviously it should hide header text if unchecked). I have no idea should I add some specific CSS for this to work or do I have to change my functions.php? Any thoughts or suggestions? My functions.php for header support looks like this:

//Code for custom header support
$defaults = array(
'default-image'          => '',
'random-default'         => false,
'width'                  => 750,
'height'                 => 100,
'flex-height'            => true,
'flex-width'             => true,
'default-text-color'     => '#FF0000',
'header-text'            => true,
'uploads'                => true,
'wp-head-callback'       => '',
'admin-head-callback'    => '',
'admin-preview-callback' => '',
add_theme_support( 'custom-header', $defaults );

CSS looks like this:

a:link, a:visited{
text-decoration: none; 
color: #000000;

color: #5f5f5f;

  font-size: 54px;

#header  h1{

4 Answers 4


Chances are, the theme you are using does not take into account the Custom header settings when it puts in the Site Title and Description.

I would suggest (if you are comfortable in PHP) creating a child theme (as described here) for your theme, then copy header.php into your child theme and remove/alter the area where it puts in your Site Header.

For more great tips on WordPress basics, the same guy covers a lot in his 24 Days of WordPress series.

  • To be honest this is my first theme I build from scratch and I know that I can solve that problem by using Settings API but just wanted to know if there is a easier way for making this work. So it looks like Settings API is a way to go with this one...
    – Dejo Dekic
    Commented Mar 1, 2013 at 14:20
  • That's great. If it's a "from-sratch" child theme, then you can just dig into your header.php and work with that :). Commented Mar 1, 2013 at 16:40

I have added this code to my header.php and it worked nicely:

#header a{
<?php if(get_header_textcolor()=='blank') { 
echo 'visibility: hidden;'; } else { 
color:#<?php echo get_header_textcolor();  } ?>

@Dejo Dekic
This solution worked! for example, if you need to show the header text only when you enable(check) it, then in header.php you should have a code like this:

<?php if(get_header_textcolor()!='blank') { ?>
<!-- here is just a good example of a normal header text -->
<a href="<?php echo home_url();?>" style="position:absolute;top:100px;left:20px;color:#<?php echo get_header_textcolor();?>!important;"><?php bloginfo('name');?></a>
<?php } ?>

Dejo's solution works , but not placing h1 and h2 tags is bad for SEO_

This is why normal WP installation just hides it leaving it in it's place, in this way it will remain visible to spiders;

For ex.: Twenty14 theme relies on filteringCSS to hide Header-Text, take a look at custom-header.php (line69 - twentyfourteen)

    // Has the text been hidden?
    if ( ! display_header_text() ) :
    .site-description {
        clip: rect(1px 1px 1px 1px); /* IE7 */
        clip: rect(1px, 1px, 1px, 1px);
        position: absolute;
    // If the user has set a custom color for the text, use that.
    elseif ( $text_color != get_theme_support( 'custom-header', 'default-text-color' ) ) :
    .site-title a {
        color: #<?php echo esc_attr( $text_color ); ?>;
<?php endif; ?>

so if you want to use this function place the right .site-title & .site-description markup (if you don't know look at twenty14 header.php)_

by the way using clip:rect(1px, 1px, 1px, 1px) is like looking at something a rectangular screen with no height or width ,(awesome solution!!!)_

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.