Hello and welcome everyone, to a Blogger T&T I should’ve written way sooner!
In the sidebar of my blog, you’ll find a “random post” link. It’s the one with the shuffle icon, go give it a shot! Just admiring that isn’t what you came here for though, you probably want to know how to implement one of those yourself. That’s what you’ll be learning today! As far as basic skills go, I’ll be assuming you know how to add a HTML widget to your blog. You’ll also need to enter some code into your Blogger template, but I’ll walk you through that, no worries!
So what will we do with these? You’ll want to go to your Blogger template page, the one which shows you a thumbnail of your blog’s current look. There’s two buttons underneath it. Hit the “edit HTML” one, and a window with code will pop up. (It may ask you if you’re sure you want to continue. Go ahead and say yes.)
Hit the orange “save template” button, and you’re ready to go!
What you just did was put a script in your blog template, so that it’s accessible on every page. The script will be called when a user clicks a special link, which we’ll be implementing now!
This part is really simple. Wherever you want to link to a random blog post, just use the following code:
<a href=”#” onclick=”feelingLucky()”>This is a link</a>
It’s that simple! Throw it in a widget, in a blog post, or edit it straight into your blog’s template if you’re bold enough! Of course, you can replace the “this is a link” part with whatever you want. Images and such are allows as well!
I hope this’ll do the trick for you. If it doesn’t, feel free to hit me up in the comments below, or shoot me an email or something. I’m always ready to help, so don’t be afraid to ask!