Header Image Rotator for Twenty Ten theme of WordPress 3.0



WordPress 3.0 is still in RC1. I have already upgraded this blog to this version. I can’t but  simply love the new theme ‘Twenty Ten’ which is default in WordPress 3.0. It is super simple theme.

In this theme, there is option to use custom header image. From the admin panel you can select the header image. However, all of the default banners looked interesting to me and I have also uploaded some of my own shots. I wanted to show them all.

Keeping that in mind, I made this simple plugin, Twenty Ten Image Rotator. Having this plugin installed, you can show all images on the header. Single banner each selected randomly on each page load.

I believe if you love Twenty Ten theme, you will love this plugin too :) .

Download from WordPress Plugin Repo

No related posts.

This entry was posted in Open Source, PHP, Scripts, WordPress and tagged , , , , , , , , , . Bookmark the permalink.

84 Comments

  • At 2010.07.21 10:50, Zach said:

    Not sure I understand why… What is TwentyTen doing that prevents a javascript rotator?

    • At 2010.07.21 17:36, kevin said:

      @matthew w. your fix worked for me! thanks. but i tried to delete the default images in the headers folder and just leave custom ones still works but i think by default it tries to find those default ones and sometimes my banner shows up blank white (http://kevinkwok.com/QQ/)

      • At 2010.07.22 01:20, Matthew Wilcoxson said:

        @kevin

        Make sure you’ve commented out (or deleted) the original static array that adds the default images in. It starts at the line with: register_default_headers( array(
        all the way (about 60 lines later) to: ));

        • At 2010.07.22 02:52, kevin said:

          @matthew works great now thank you so much

          • At 2010.07.29 17:32, Atze said:

            @ Matthew Wilcoxson

            I still don´t know, which lines I have to delete and where I have to put your lines. Can you just send me your edited functions.php as a zip???

            thx, atze

            • At 2010.07.30 17:31, Atze said:

              Okay I renamed all my images like “berries.jpg” and so on …
              Haa, new WP 3.01 installed automatically and all my images are away and the old Twenty Ten images are back. bäh …
              Isn´t it possible to use a headers folder outside the twenty ten theme??

              • At 2010.08.02 22:51, Matthew Wilcoxson said:

                If anyone is interested I’ve created a child theme to hold the new code that gets the headers. When you upgrade TwentyTen it should avoid overwriting anything you’ve written. Take a look at my blog entry “TwentyTen wordpress child hacks”, second half.

                • At 2010.08.06 23:23, joe said:

                  Hi, when starting out with a few images it worked OK. When I added a few more I got a “page loading” hang on several browsers, so it’s not a cache issue. Is there some way of preloading the images or making the load time less onerous?

                  • At 2010.08.09 03:07, joe said:

                    What would it take to make the slides auto rotate instead of event triggered?
                    I need something with fade between slides so I’m open to suggestions

                    • At 2010.08.20 05:06, Isaac said:

                      Just what I need for a wp project. Thanks a lot!

                      • At 2010.08.23 02:43, Evan said:

                        I’m so confused. How can I get just my images to rotate?

                        Evan
                        churroblog.com

                        • At 2010.08.30 21:01, navid said:

                          As many others I have been looking for a plugin to have rotating header in Twenty Ten… this plugin is part of the solution. The rest of the solution can be found here: http://www.wpbeginner.com/wp-themes/how-to-enable-custom-header-images-panel-in-wordpress-3-0/

                          I hope it helps you all
                          Navid

                          • At 2010.08.31 12:26, The HungryCoder said:

                            That seems a very good article! Thanks!

                            • [...] HungryCoder的“Twenty Ten Header Rotator”插件即可。功能描述:Rotate header images for Twenty Ten [...]

                              • At 2010.10.03 05:36, John said:

                                To rotate custom images just replace the default images with your own and give them the same name that’s already there. For example one of the jpgs is path.jpg. Just create a custom image and name it path.jpg then over write the one that is already there. Then you don’t have to mess with any coding.

                                • At 2011.01.14 19:06, Cat Lady said:

                                  I tried that and it didn’t work. I don’t understand all of this coding stuff yet so I was looking for what i thought would be the easiest way. I put the images in the correct folder, but nothing happened. What am I doing wrong.

                                • [...] use my own images for the Twenty Ten header I borrowed some code provided by Matthew on the Twenty Ten Header Rotator plugin site. I replaced the following code in functions.phpregister_default_headers( array( 'berries' => [...]

                                  • At 2010.11.03 05:26, Marty Shue said:

                                    @Matthew
                                    Thanks for the code! I finally got this plugin to work. Thanks also to everyone that commented. I pieced together bits of information and got it to work perfectly.

                                    • At 2010.12.05 14:49, Kevin said:

                                      this seemed to work for me on an older blog, and I have been designing a new and tried to use it again but I think its not compatible with newest version of wordpress =(

                                      • At 2010.12.09 13:36, jon said:

                                        can this work on twentyten child themes? more specifically Atmosphere 2010. I really want to be able to rotate my site’s header.

                                        • At 2011.01.09 23:01, Marius said:

                                          Highly Highly thanks!!! For solution “edit funtions.php and change the image names in the code to your custom image’s names”!!!

                                          • At 2011.01.10 02:23, John said:

                                            When you create your own images give them the same exact names that are already uploaded in to the themes image directory, that way they will overwrite the ones that are already in there. It is that simple. You may also go in to the functions.php file and rewrite the following code to the names of your images, but the first way is much simpler. That way when you do a wordpress or theme update all you have to do is reupload the images since they get replaced with the default ones.

                                            • At 2011.01.10 02:29, John said:

                                              I’m sorry I forgot to show you the code:

                                              ‘berries’ => array(
                                              ‘url’ => ‘%s/images/headers/berries.jpg’,
                                              ‘thumbnail_url’ => ‘%s/images/headers/berries-thumbnail.jpg’,
                                              /* translators: header image description */
                                              ‘description’ => __( ‘Berries’, ‘twentyten’ )
                                              ),
                                              ‘cherryblossom’ => array(
                                              ‘url’ => ‘%s/images/headers/cherryblossoms.jpg’,
                                              ‘thumbnail_url’ => ‘%s/images/headers/cherryblossoms-thumbnail.jpg’,
                                              /* translators: header image description */
                                              ‘description’ => __( ‘Cherry Blossoms’, ‘twentyten’ )
                                              ),
                                              ‘concave’ => array(
                                              ‘url’ => ‘%s/images/headers/concave.jpg’,
                                              ‘thumbnail_url’ => ‘%s/images/headers/concave-thumbnail.jpg’,
                                              /* translators: header image description */
                                              ‘description’ => __( ‘Concave’, ‘twentyten’ )
                                              ),
                                              ‘fern’ => array(
                                              ‘url’ => ‘%s/images/headers/fern.jpg’,
                                              ‘thumbnail_url’ => ‘%s/images/headers/fern-thumbnail.jpg’,
                                              /* translators: header image description */
                                              ‘description’ => __( ‘Fern’, ‘twentyten’ )
                                              ),
                                              ‘forestfloor’ => array(
                                              ‘url’ => ‘%s/images/headers/forestfloor.jpg’,
                                              ‘thumbnail_url’ => ‘%s/images/headers/forestfloor-thumbnail.jpg’,
                                              /* translators: header image description */
                                              ‘description’ => __( ‘Forest Floor’, ‘twentyten’ )
                                              ),
                                              ‘inkwell’ => array(
                                              ‘url’ => ‘%s/images/headers/inkwell.jpg’,
                                              ‘thumbnail_url’ => ‘%s/images/headers/inkwell-thumbnail.jpg’,
                                              /* translators: header image description */
                                              ‘description’ => __( ‘Inkwell’, ‘twentyten’ )
                                              ),
                                              ‘path’ => array(
                                              ‘url’ => ‘%s/images/headers/path.jpg’,
                                              ‘thumbnail_url’ => ‘%s/images/headers/path-thumbnail.jpg’,
                                              /* translators: header image description */
                                              ‘description’ => __( ‘Path’, ‘twentyten’ )
                                              ),
                                              ‘sunset’ => array(
                                              ‘url’ => ‘%s/images/headers/sunset.jpg’,
                                              ‘thumbnail_url’ => ‘%s/images/headers/sunset-thumbnail.jpg’,
                                              /* translators: header image description */
                                              ‘description’ => __( ‘Sunset’, ‘twentyten’ )
                                              )

                                              We will use the sunset code for example:
                                              ‘sunset’ => array(
                                              ‘url’ => ‘%s/images/headers/sunset.jpg’,
                                              ‘thumbnail_url’ => ‘%s/images/headers/sunset-thumbnail.jpg’,
                                              /* translators: header image description */
                                              ‘description’ => __( ‘Sunset’, ‘twentyten’ )
                                              )

                                              and the name of your image is mountains.jpg. Your code will look like this:

                                              ‘mountains’ => array(
                                              ‘url’ => ‘%s/images/headers/mountains.jpg’,
                                              ‘thumbnail_url’ => ‘%s/images/headers/mountains-thumbnail.jpg’,
                                              /* translators: header image description */
                                              ‘description’ => __( ‘mountains’, ‘twentyten’ )
                                              )

                                              Just make sure your images are the same dimmensions that are already upload. Both the main image and the thumbnail image.

                                              • At 2011.02.26 03:57, Jenn said:

                                                Hi John. Thanks for the tip. My header images keep getting wiped out with each update so I’d like to do it this way. Where exactly in the functions.php do you place this code?

                                                Here’s what’s there so far:

                                                <?php

                                                add_action( 'after_setup_theme', 'child_theme_setup' );

                                                if ( !function_exists( 'child_theme_setup' ) ):
                                                function child_theme_setup() {
                                                define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 880 ) );
                                                define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 236 ) );
                                                }
                                                endif;

                                                Thank you for your help! I'm new to php…

                                              • At 2011.01.13 22:32, Cat Lady said:

                                                Is there a way I can use my own images with this plug in. I am fairly new to this but I was able to edit it to take my newly created image. But my friend would like to see my own rotating header images
                                                Thanks

                                                • At 2011.02.02 04:20, carla cuomo said:

                                                  hi there I d like to use my own images with this plugin but I am quite lost…..I ve installe the plug but I don’t know where I suppos to upload the images to rotate
                                                  thanks

                                                  • At 2011.02.11 00:22, Danny said:

                                                    Lee- Name the images exactly the same as the ones in the original header folder. Make sure you have the same number of images as the original or you will get blank headers from time to time.

                                                    • At 2011.02.23 02:42, Ewien van Bergeijk - Kwant said:

                                                      hi there, thanks for this rotator…very cool.

                                                      is there any way I could use my own top 5 pics instead of the default ones given by WP? Thnx!

                                                      • At 2011.02.24 19:20, Atze said:

                                                        doesn´t work with wp 3.1 … ???

                                                        • At 2011.02.25 00:00, Richard said:

                                                          How can I set a default image which will be shown at first?

                                                          • At 2011.02.25 08:16, Richard said:

                                                            You use WP 3.1 + TT 1.2 and the rotator works. How did you manage that? After my wordpress update the plugin is broken.

                                                            • At 2011.02.27 18:49, Richard said:
                                                              • At 2011.03.04 22:32, Greg said:

                                                                Rotator is not working on latest Worpress release, and actually generates this error and dosen’t show anything else of the site : Fatal error: Cannot redeclare class Custom_Image_Header in /home/xxxxxx/public_html/wp-admin/custom-header.php on line 16

                                                                • At 2011.03.08 11:46, The HungryCoder said:

                                                                  Hi,
                                                                  I just released an update of this plugin. You should already get update notification in your wordpress admin area. Please update to latest version and let me know whether it works on 3.1 or not. In fact, this plugin was working on a number of blogs while not working on a few due to inclusion of a file twice (i guess). I believe it would be fix by now.

                                                                  Thanks

                                                                • At 2011.03.05 17:34, Twenty Ten Header Rotator « Kaddel's Blog said:

                                                                  [...] Die Bilder werden in einem Unterordner gespeichert. Hier geht es zur Homepage des Entwicklers: [...]

                                                                  • At 2011.03.08 10:26, Eric said:

                                                                    Fatal error: Cannot redeclare class Custom_Image_Header in /home/XXXX/public_html/wp-admin/custom-header.php on line 16

                                                                    Yep! I thought I was going insane! I get all the same errors. I thought I broke something because I was just renaming path and using my own image but…Thanks. I’ll try a few other solutions.

                                                                    • At 2011.03.08 11:12, Eric said:

                                                                      http://www.callum-macdonald.com/code/wp-random-header/

                                                                      I’m a lazy bastard. But this plugin works! No BS of renaming files to match path and forest floor etc..etc… Just grab yourself a folder name it to header-images throw all your jpgs in it tho, you should resize them and make sure they look good @ 940×198 (twenty ten default layout).

                                                                      Then just throw the folder across onto the root directory of wp-content/ VALA! Works in 3.1 WP! :)

                                                                      Cheers!

                                                                      • At 2011.03.08 13:18, Atze said:

                                                                        yeah, it works

                                                                        • At 2011.03.08 19:01, boris said:

                                                                          Thanks for the update, 1.3 works like a charm with WP3.1 :)

                                                                          • At 2011.03.08 21:24, KubaSEO said:

                                                                            Great Plugin Thanks

                                                                            • At 2011.03.15 02:11, Ken said:

                                                                              I updated the plugin, but now my images aren’t loading properly. They’ll either not load at all or only partially load.

                                                                              I haven’t upgraded to 3.1 yet. Not sure when I will. Is there a way I can use the previous version of this plugin?

                                                                              • At 2011.03.15 11:33, The HungryCoder said:

                                                                                Hello Ken,
                                                                                I believe the problem is with something else. In the new version of this plugin there is no change made that could cause such problem. Technically, the change was from ‘require’ to ‘require_once’.

                                                                                However, you can download any version from here:
                                                                                http://wordpress.org/extend/plugins/twenty-ten-header-rotator/download/

                                                                                Thanks

                                                                              • At 2011.03.15 11:41, Ken said:

                                                                                Hmmm…yeah, that doesn’t seem like it would cause such a problem. Maybe I’ll do the tried and true troubleshooting technique and reboot first. Haha.

                                                                                Thanks!

                                                                                • [...] Header Image Rotator for Twenty Ten theme of WordPress 3.0 | The HungryCoder. This entry was posted in Uncategorized. Bookmark the permalink. ← Welcome to the Eagle [...]

                                                                                  • At 2011.04.17 18:44, Evert said:

                                                                                    Hi,
                                                                                    I have replaced all the pictures in the header by my own, using the same names as the originals. However I have deleted first the original picture in the header function.
                                                                                    Now I sometimes get a blank header. Any idea how I can solve that?

                                                                                    Kind regards,

                                                                                    Evert

                                                                                    • At 2011.04.17 18:45, Evert said:

                                                                                      Where do I place this code?

                                                                                      Kind regards Evert

                                                                                      • At 2011.05.06 18:54, bvo said:

                                                                                        is there a way to have a specific header image with a specfic post, like “if post is usa, then use image usa” and “if post is canada, then image is canada”?

                                                                                        • At 2011.11.29 18:44, marv said:

                                                                                          how do u get rotating header to work? i went to appearance. header but dont see what to do

                                                                                          • At 2012.01.30 06:05, mamta said:

                                                                                            I have intalled it but dont know how to use it please help me out..
                                                                                            thanks

                                                                                          • 34 old comments are not displayed. Click to display all comments
                                                                                          (Required)
                                                                                          (Required, will not be published)