- 1). Log in to your Wordpress admin control panel, then click "Media" and ""Add New." Click "Select Files" and navigate to the location of your banners on your computer's hard drive. As you upload each one, copy and paste the "File URL" of each file into a text document, and click "Save all changes" before uploading the next banner. Repeat until you have uploaded all your banners.
- 2). Click "Appearance" from the main menu bar on the left, then click "Editor." From the list of files on the right, click "header.php." Copy the following code between the "<head>" tags in the "header.php" file:
<SCRIPT LANGUAGE="JavaScript">
var maxBanner = 3
var BannerNo
var myBanner = new Array()
myBanner[0] = '<img src="URL 1" alt="banner 1" />'
myBanner[1] = '<img src="URL 2" alt="banner 2" />'
myBanner[2] = '<img src="URL 3" alt="banner 3" />'
</script> - 3). Replace the "3" next to "maxBanner = 3" with the number of banners you are using, then change "URL 1," "URL 2" and "URL 3" to the URLs you noted down in Step 1. If you are using more than three banners, copy and paste the line starting with "myBanner[2]" into a new line just below it, and replace "[2]" with "[3]." Repeat for all your banners and click "Save Changes" when done.
- 4). Scroll down in the file until you locate the "<img>" tag for your current banner. If you cannot find it, load your blog in a browser, then right-click the banner and open it in a new window. Note the image's URL in your browser's address bar, then scan the "header.php" file for the "<img>" tag that contains this address.
- 5). Delete the "<img>" tag and replace it with the following code:
<SCRIPT LANGUAGE="JavaScript">
BannerNo = Math.round(Math.random() * maxBanner)
document.write(myBanner[BannerNo])
</script> - 6). Click "Save Changes" to save your work.
previous post
next post