Techniques » Remove default WordPress Twenty Ten header images

How do you remove those pesky default header images included in the Twenty Ten WordPress theme. We recently used the Twenty Ten theme as a Parent Theme for a multi-site installation for a client. We wanted to retain the use of the custom header image, but didn’t want the default header images to be visible. It is accomplished with a few lines of code in the Twenty Ten child theme’s functions.php file. You are using a child theme, aren’t you?

First define a new function, we used remove_twenty_ten_headers(). We use the unregister_default_headers() WordPress function to un-register as many as we want. In our example we removed them all.

1
2
3
4
5
6
7
8
9
10
11
12
function remove_twenty_ten_headers(){
    unregister_default_headers( array(
        'berries',
        'cherryblossom',
        'concave',
        'fern',
        'forestfloor',
        'inkwell',
        'path' ,
        'sunset')
    );
}

We then initiate the new remove_twenty_ten_headers() function using the add_action() WordPress function as shown below. We make sure to call our function after the theme setup has run to be sure our function is called after register_default_headers() has already added the headers we want to remove.

1
add_action( 'after_setup_theme', 'remove_twenty_ten_headers', 11 );

Putting it all together yields the following code to be placed in your theme’s functions.php file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* Remove default twenty ten images ***********************************************/
function remove_twenty_ten_headers(){
    unregister_default_headers( array(
        'berries',
        'cherryblossom',
        'concave',
        'fern',
        'forestfloor',
        'inkwell',
        'path' ,
        'sunset')
    );
}
add_action( 'after_setup_theme', 'remove_twenty_ten_headers', 11 );

How simple is that!

About Corey

Corey was born, raised, and still lives in CMCH, NJ (about 5 minutes outside of Wildwood). He loves the Jersey Shore, and has loads of sand in his shoes! He has been involved with computers and programming since first purchasing a Commodore 64 in 1984. Corey formally began a web design company in 2004, ever broadening his progamming languages and skills since. code

3 Responses to Remove default WordPress Twenty Ten header images

  1. GreenFuture says:

    Cool !
    It is a miracle…It actually worked.
    now if you can explain how to add images that are more proper to the site i’m working on it could be great

    Thanks

    • Corey says:

      You can add images by uploading them in the Admin area under Appearance -> Header, use the Browse input and upload. You can also have specific images per page/post by using the Featured Image box on the right hand side of the edit area for each page or post.

  2. lucas says:

    Honestly, how hard would it have been for the WordPress team to have a remove button built into the admin tool rather than having users google the solution and write custom functions to do it!!!!! sorry to rant but it pisses me off that they don’t think of the OBVIOUS!!!!

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>