How to replace default rotating header images with my own

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.

Read More

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.

TIA

Related posts

Leave a Reply

1 comment

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

    Then first remove the default images:

        // REMOVE TWENTY ELEVEN DEFAULT HEADER 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:

        //ADD NEW DEFAULT HEADER 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