How to create a random banner in WordPress

At the bottom of this page you can find a simpler solution to this question.

I have currently removed the random banner from my design. Not because it didn’t work well, but because I wanted a simpler design.

As you might have noticed, the banner at the top of this site changes as you navigate the site. To implement this in WordPress is quite simple.

You need this plugin:
Random Banner
Random banner how to install

And a couple of banners. I made mine with a template I made in Photoshop. You can download my template here:
Template to edit the default banner in WordPress

Or you can make a couple of banners using this tool:

When you have set up Random Banner and made some top banners, place them in the random banner folder as noted in the instructions for the plugin.

Activate the Random Banner plugin.

Now you need to edit line number 27 in “header.php” for your current theme. You should replace the existing line 27 with this one:
#header { background: url("") no-repeat bottom center; }

NOTE: I have not bothered to install a plugin that lets me print pure PHP-code on my page, so you can not copy line 27 directly from here. You need to delete the space between < and ? before "php random_banner…"

…and off you go!

You can read about my current banners here.

How to create a random banner in WordPress

9 thoughts on “How to create a random banner in WordPress

  1. matt says:

    thanks for the script, I have created a file called random.php amd when i run it, it loads a different image everytime, just wondering though, as I’m new to PHP, how do i add this to my header.php on my wordpress site ?

    Currently my logo, is shown by in wordpress ! what is the best way to fix this !


  2. You just have to find the place where the link to the current header image is. It’s in your theme somewhere. Very often in the header.php-file.

    Then you replace the reference to the jpg-file with a reference to the random.php-script.

  3. computer consultant says:

    Thanks Eirik. I think this is exactly what I’ve been looking for so that I can create my own banners and place them on my WP site. Trying it out right now…

Leave a Reply to Random Banner | 《我一個人…》 Cancel reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s