WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using a child theme of twentyeleven, and I'd like to replace the default 8 images with my own - and have them rotate as the default images do with the twentyeleven theme.

Some have recommended simply replacing the default images with my own.

My concern about replacing the default images with the new ones in the twentyeleven/images/headers/ directory is that, if/when I were to update the twentyeleven theme, my custom images would be replaced with the defaults.

Also, the twentyeleven_setup() function includes a section that registers the default headers.

a) Am I right about the overwriting issue if/when I update twentyeleven?

b) If so, I'd like to know how to designate a different directory (e.g., childtheme/images/headers/) as the repository of the custom images.

I thought that simply creating that new directory and uploading an image would work; it didn't.


share|improve this question
Thanks you... this worked for me... – user13783 Mar 3 '12 at 16:27

Best way to go is to make a Child Theme of Twenty Eleven.

Then first remove the default images:

function wptips_remove_header_images() {
    unregister_default_headers( array('wheel','shore','trolley','pine-cone','chessboard','lanterns','willow','hanoi')
add_action( 'after_setup_theme', 'wptips_remove_header_images', 11 );

After that you can tell your Child theme to use your own images:

function wptips_new_default_header_images() {
    $child2011_dir = get_bloginfo('stylesheet_directory');
    register_default_headers( array (
        'image1' => array (
            'url' => "$child2011_dir/images/image1.jpg",
            'thumbnail_url' => "$child2011_dir/images/image1-thumb.jpg", // 230 x 66px
            'description' => __( 'Image Description', 'child2011' )
        ), // if you have more than one image you will need a comma between all of them, except for the last one
        'image2' => array (
            'url' => "$child2011_dir/images/image2.jpg",
            'thumbnail_url' => "$child2011_dir/images/image2-thumb.jpg", // 230 x 66px
            'description' => __( 'Image Description', 'child2011' )
        ) // the last image does not get a comma
add_action( 'after_setup_theme', 'wptips_new_default_header_images' );

You can read the entire explanation on http://wpti.ps/?p=107

share|improve this answer
may i use this code in my custom theme? – Ramkumar Sep 14 '11 at 7:16
@Ramkumar of course you may! :) – Piet Sep 15 '11 at 12:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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