I think (hope) my question is simpler than how I’ve phrased it, but this is also why I’m coming up empty on Google. It’s similar to this, but I need to handle some HTML with it and am a little unclear: Random image display
In the sidebar of my WordPress install I have two images in this order:
<a href="http://www.link1.tld"><img src="files/image1.jpg" border="0" /></a>
<a href="http://www.link2.tld"><img src="files/image2.jpg" border="0" /></a>
What’s the easiest way to accomplish rotating this order when the page is refreshed (so that the order will be image2 / image1)? And upon next refresh, go back to image1 / image2?
To accomplish this you’ll need to store a view counter in a cookie with the user and then display based on that counter:
and then to display:
If the view counter is even it will print image1 first. If it’s odd it’ll print it second.
Scaling this to more than two images could be done like this:
and then the display just loops through the ordered list: