Remove all default header images in a Twenty Ten Child Theme

Despite the beauty of (and cool stories behind) the default images in twenty ten, If you’re building a twenty ten child theme, there is a chance that you won’t want them to appear as options on the custom header screen. This simple snippit of code in your child theme’s functions.php file will deregister the default images. If you use this, I strongly encourage you to add your own in replacement. Check out my 2010 child theme tutorial to learn more about extending twenty ten.

[php]

function jorbin_remove_twenty_ten_headers(){
unregister_default_headers( array(
‘berries’,
‘cherryblossom’,
‘concave’,
‘fern’,
‘forestfloor’,
‘inkwell’,
‘path’ ,
‘sunset’)
);
}

add_action( ‘after_setup_theme’, ‘jorbin_remove_twenty_ten_headers’, 11 );

[/php]

That’s all. Happy Coding!

23 thoughts on “Remove all default header images in a Twenty Ten Child Theme”

  1. Hi Aaron, thanks for your post! I was wondering what to do if I need to get rid of the whole header image functionality. I tried to delete the code from header.php on my child’s theme but it didn’t work. If I remove image on wp-admin/custom image then I have a blank space. Any suggestions please?

  2. add_action( ‘after_setup_theme’, ‘jorbin_remove_twenty_ten_headers’, 11 );

    1. What’s that “11” at the end of the code?
    2. I followed your guide to make child the of twentyten, and added my own header images in the functions.php.

    When you are in DASHBOARD>>APPEARANCE>>THEMES,
    You see all available themes with their respective header. For example, the defoult twentyten has “path” header.

    But when I am in the Dashboard>>theme, although my child theme is listed among the available themes (DASHBOARD>>APPEARNCE>>THEMES) but without my selected header image. However I can see it in Dashboard>>Appearance>>Header

    Also, when I view it in the browser it does display the selected header image.

    Question: I just wonder why my child theme in the DASHBOARD>>APPEARANCE>>THEMES is not accopanied by its selected header image?

      1. Hi Aaron,

        Thank you for your help.

        Thank s for the child theme guidance. Eventhough I am not a dev, programmer or a pro, I was able follow your guide.

        In response #2 you said ” Themes is based on the screenshot.png file”.

        But all Twentyten and Thityten thumbnails are .jpg files, and they all show up in “Awailable” themes. Mine thumbnail is also a .jpg file and does not.

        Since I am not a pro in all this, I am sure I missing simething. Please guide. Thanks again.

        1. SOrry if I wasn’t clear, The screenshot used in Appearance > Themes is not generated on the fly, but is instead a static screenshot that is in the theme folder as screenshot.png (or as a ‘gif’, ‘jpg’, or ‘jpeg’). You should take a screenshot and save it in your child theme directory if you would like it to appear there.

  3. How would you go about removing the ability for users to upload their own header? Our modified theme will be used in a branding situation where we want the users to only be able to select images provided by the marketing group. I’m sure it is just a function or something I have to unhook, but I couldn’t find anything in the codex or the web. Thanks.

      1. Hmm. Maybe I did something incorrectly. I applied the patch to my 3.0.1 dev install and added remove_theme_support(‘custom-header-uploads’); to the Twenty Ten child theme’s functions.php and still had an option to upload when I visited the Header page. I was logged in as Super Admin, but that shouldn’t matter if the support for the option is removed.

        1. If the patch makes it in as is, It is going to require that remove_theme_support(‘custom-header-uploads’) be called after add_custom_image_header is called, so that could be your problem. I’m trying to think of a better solution now so it doesn’t have to work like that.

  4. Hi Aaron,

    First of all, thank you for your article of course. I have to say, I tend to work the same way as you do. Cleaning things up first, and then build upon. Besides, I enjoy working upon Twenty Ten as my theme framework.

    The excising default headers however didn’t bother me that much however, I just added my own one:
    array(
    'url' => "$24_design_dir/images/headers/24design.jpg",
    'thumbnail_url' => "$24_design_dir/images/headers/24design-thumbnail.jpg",
    /* translators: header image description */
    'description' => __( '24design by Cor van Noorloos', '24design' )
    )
    ) );
    }
    ?>

    My main problem however is, my newly created header gets sometimes overruled if a large featured image is been used.

    Would there be a way to unregister this feature somehow?

      1. Hi Aaron, thank you for your reply. Thumbs up for commenting on a rather old article btw. There aren’t many people who support all of their articles well.

        Using the code above, I’ve removed the featured image bit from the header.php, and just left the header_image bit.

        Currently working on a movie database, featured images are a real timesaver for me and my client. Just not in the header.

        1. In that case, I think you’re going to have to modify the header.php file and change the header image business that is currently around line 70. Essentially take out the if statement, and just use the information in the else.

          Of course by doing this you’re going to have to make sure you stay current on the rest of the changes to the header.php in case there are other changes.

  5. I think the header images are great, though I don’t want them on every page. Is there anyway to keep the functionality, but omit or deactivate the custom headers on specific pages?

  6. I want to remove the image completely from my twenty-ten themed blog (don’t want to give up the real estate to an image that big). (I am not creating a child theme – nowhere near that knowledgeable about this, just going with the default provided.)

    I found how to do this when I first installed wordpress to my website (hosted at GoDaddy): ExploreUtah.com. I believe it was a tweak to the header.php file. Unfortunately for me, I didn’t save the webpage that gave me the advice, nor did I write it down. (I think the code was something about ” if..then, if no image selected, then don’t provide a space for one).

    Today I updated the software and so the tweak is gone and now my blog shows a big empty image.

    Can you help?

Leave a Reply

Your email address will not be published. Required fields are marked *