WP Random Header

A simple plugin that uses randomly picks a header image from the files in wp-content/header-images. Install, activate, that’s it.

Put only image files in wp-content/header-images. The plugin will choose any files from that directory, so other file types will mess things up.

The plugin only sets the image url, not the size, so all images should be the same size and the same size as the standard image header for your theme. That’s 1000×288 for twentyeleven or 940×198 for twentyten.

The plugin does not deactivate the custom header image functions of any themes. So your theme might still allow you to set the image header, but this plugin will most likely override it.


If you cannot make this plugin work, please try another. I’m not willing to provide support for this plugin. Please respect that decision and do not ask support questions of me. If you find a bug, or the plugin does something you think it shouldn’t, please let me know in the comments here. Also, if you’d like to take over maintenance of this plugin and provide support, let me know. 🙂


Get the code on wordpress.org.

59 thoughts on “WP Random Header”

  1. So I looked at the code for both the WP.org download and your site’s download.

    That code is obviously the wrong stuff. The example I sent earlier is the result of a var_dump on an array that is not even initialized to anything.

    Would like to see the real plugin that generates the random header for your site. And I might be willing to take it over.

    1. You’re absolutely right, my apologies. I committed the wrong code altogether. That was an early version. I’ve committed the most recent code now, it’s in svn and I think it’ll be on wp.org within an hour or so. Let me know how you get on with it.

  2. Hi. I know there’s no support for this, but maybe someone else out there who uses this plug-in can help…? I want to know if there is anyway to add a default image? In other words, is there a way to have one image appear the first time the page is loaded and then as the page is reloaded the images are randomly chosen? Also…is there any kind of timer that can be implemented so that there is an option to be more like a slideshow?
    -just curious – thanks!

    1. These features will exist if you wish to write the code, today, these options do not exist and I have no plans to implement them.

  3. Hi, this works perfectly and was exactly what I was looking for. Just wanted to say thanks!

  4. Just wondering if this plugin over-rides the ability to have a default image for a specific post or page? I would like to have random images on most of the site but on pages/posts specific to one of my projects I would like to set the image to that particular project. Thanks.

    1. Simple answer, I’m not sure. You could install and test. There might be a solution around setting the priority for the ‘theme_mod_header_image’ filter. If it does override a specific post image, I’ll consider that a bug and try to find a simple fix. I can’t promise how quickly I’ll be able to do that though. Please let me know if you’re able to test it.

      1. It works great, at least with the twenty ten theme. Actually just finished trying it out when you posted that reply. So, here’s the deal:

        Install it as directed
        If you have a post/page you want to set a featured image, just do so & it will over-ride the random header..

        Have no idea about other themes though..

  5. Just wanted to let you know that I’m using your plugin with twenty-ten and it works great. My blog now has a lovely selection of rotating header images.

  6. Hi, I have installed your plugin with Twenty Ten. There appears to be no way of uploading more than one header image, please advise? I notice that others have got it to work.

    1. As per the first sentence on this page, the images go into wp-content/header-images. Have you put multiple images in a folder called header-images inside the wp-content folder?

      There is no way that I know of to upload the images through WordPress. I believe you’ll need to put them onto your server by FTP or some other means.

  7. Callum, thank you for writing such an elegant and simple piece of code that saves folks hundreds of man-hours from needing to reinvent the wheel every time this kind of functionality is wanted.

    I ran into a problem that I was able to troubleshoot myself and wanted to point out to others just in case they face the same problem. This script will grab and post ANYTHING you put into the wp-content/header-images, so make sure it’s completely empty except for the images you want displayed. While constructing a site using XAMPP on an XP box I kept randomly finding the header space blank (just white background) instead of a picture loading. After a day of thinking about it, I forgot that Windows likes to do crazy stuff sometimes, like add hidden files to folders (in this case a hidden thumbs.db). So if you’re testing on a Windows environment and face the same problem, check to make sure you don’t have hidden files in the header-images folder. Thanks again!

    1. Thanks for the kind words, and thanks for sharing your experience. I hadn’t thought about Windows hosts, you make an excellent point. I knew the plugin picked up any type of file in the directory. I could have written something to check for images only, but to do that properly would require quite a bit of thought and code. I wrote this really for my own use and I know to keep the directory clean, so it’s not an issue for me. Glad you figured out the challenge. I’ll maybe add something to the documentation to make this point clearer, that’s probably a good idea.

  8. Hey Callum great work!

    I have uploaded the plugin and followed your directions exactly, it works fine but sometimes my images will come out distorted or pixelated. (maybe like 10% of the time) The pictures are to perfect size and im extremely confused! if you could help me out that would be so great!

    1. Can you figure out why the images are distorted? In Firefox, if you right click on the picture and click “View image” that should load the image alone. Then you can check the URL and see if it’s a proper image. Try also pressing CTRL-SHIFT-R, which will hard refresh (bypassing the browser cache). If the image reloads properly, it’s a cache corruption or a browser issue. If you find something else wrong, let me know and maybe I can point you in the right direction. From what you’ve said about the issue, there’s no reason the plugin would cause that issue.

  9. I love this plug in, but is there a way to make the images rotate without reloading? I mean can they rotate in 2 to 3 second intervals?

    1. Absolutely not. This plugin uses a feature built into WordPress to select a header image at random. Causing the head image to change in place would require a totally different approach, probably based on javascript. It’s not something I can ever see adding to this plugin. However, it would be reasonably easy to implement, if you can’t find a plugin that does this I think it would be easy to commission one on the likes of vWorker.

      1. Got it. Thanks so much for your response. However, I do not understand “vWorker”. Is that a site or a component of WordPress?
        Thanks again.

  10. Never mind on the vWorker response. I Googled it and see it is a site whereby I can post projects to be done and receive bids on them. Thanks bunches for the tip.

    1. Are you asking for support? I deleted your earlier comment because I couldn’t see the relevance, the email you gave appears to be fake and so I thought your comment was link spam.

  11. Hi! I have set your cool plugin on my site. How i can when i clicking on the image in the header to move to the home page? i wanna see active header with link on home page. thnx

    1. I’m sorry, I don’t understand your question. I’m guessing that the plugin doesn’t do what you want. It only randomises the header image, it doesn’t do anything with links and so on.

      1. Can I make the header of the site has become clickable and when you click on header it moved us to the homepage or something URL? (sorry my english is bad)

  12. I want to know how i can make it. When you are click on header images – you will moved on homepage. Its simple. if you can do it, please. All people want it.

  13. Hi ,
    Your plugin is excellent .
    Unfortunately it’s not working on the Thesis framework .
    Thanks anyway 🙂

  14. Great plugin! Very easy to install.

    Just mentioning this in case anyone gets inspired to write some fade-in/fade-out code for this plugin. I’d be very interested.

    1. That would make sense as a separate plugin I think. To fade in / out would require javascript or creating animaged gifs (a horrible option). The javascript approach would be quite different to how this plugin works, so I can’t imagine it would end up in the same plugin. But it’s definitely possible. If you’re willing to fund the development, we could discuss privately in more detail.

  15. Hi, I’ve just installed your plugin and it’s great. I’m new to WP, please can you tell me how I can remove some of the images I have uploaded that I do not wish to use in the rotation.

    1. From the top of this page: “If you cannot make this plugin work, please try another. I’m not willing to provide support for this plugin. Please respect that decision and do not ask support questions of me.”

  16. Hello
    I need advice the plugin works on some of my sites but when the css looks like this /* begin Header */
    margin: 0 auto;
    position: relative;
    width: 870px;
    height: 250px;
    position: absolute;
    top: 0;
    left: 0;
    width: 870px;
    height: 250px;
    background-image: url(‘images/Header.png’);
    background-repeat: no-repeat;
    background-position: left top;
    position: absolute;
    top: 0;
    left: 0;
    width: 870px;
    height: 250px;
    background-image: url(‘images/Header.jpg’);
    background-repeat: no-repeat;
    background-position: center center;
    /* end Header */
    I do not what to enter for it to work for me Can you please help me out.
    Thank you

    1. RTFM: “If you cannot make this plugin work, please try another. I’m not willing to provide support for this plugin. Please respect that decision and do not ask support questions of me.”

  17. Callum, thank you for the plugin. I was a bit nervous about the ‘no support’ disclaimer (btw, reading some of the comments here I can see why you’d say that); however I’ve just installed the plugin, followed the instructions, and it works just fine.

    So, for people struggling to make the plugin work, here’s what I did: Use the Twenty Ten theme – I had troubles using other themes. Load a selection of .jpg images sized 940×198 pixels into a directory/folder called ‘header-images’ located just inside the wp-content directory/folder. Install and activate the plugin. View your site’s pages/posts. If the images are ‘sticking’ i.e. not changing, try forcing a reload from the server – ctrl-f5 (pc) or opt-r (mac).

    Thanks again, Callum, keep up the good work.

  18. Hi there

    Ive got the weaver theme as my activated theme. I cant see where it is even when ive activated the random header plugin. Could you please give me some advice?

    1. RTFM.

      If you cannot make this plugin work, please try another. I’m not willing to provide support for this plugin. Please respect that decision and do not ask support questions of me.

  19. Hi,
    as I can see pictures rare taken from this source: wp-content/header-images

    Would it be possible to get pictures from a different location? The reason for asking is, if (like I do) have a WP multisite setup, all blogs using the plugin would have the same images to be displayed.

    Please don’t comment and shout at me with your RTFM etc. comment, unfortunately there is no plugin having the ability to setup different random header sets or ‘let’s call it groups by folder’ or similar to achieve having different blogs with different images.


      1. Yah, I’d be willing to pay for it to work separately on a multi site, as I am building http://offthewhitemonkeyroad.com/. Would like a different set of rotating pictures for each country. Give each country a different feel as people are traveling virtually. Works great with this theme Landscape, by the way. 🙂

        1. Sure thing, shoot me an email (a reply to the comment notification should work) and we can discuss your precise requirements.

  20. Thank you, just what I needed! I’m using it with Pico Light, which looks like a child of 2011. The stock WP random image picker is slow, hard to change or adjust, and corrupts if there are certain server changes made. And the stock images are hard-coded, very helpful!

  21. Hi man!
    I was wondering if WP Random Header works with WordPress sites with Network enabled. I’ve used the plugin on other sites and it’s brilliant! Now I’ve a networked WordPress site with multiple blogs. And I’d like to have a standard layout for all blogs, including having the your Header in all of them. Do you think it’ll work? I just tried but I can’t see the header showing up…


Leave a Reply to Callum Cancel reply

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