Late last night I was working on one of my friends image based website and there he asked me to create next, previous and a random button under the single post (image). I searched around the same niche and found that a few of the site were using something like: www.site.com?random=1 or in general a Get variable to check for the user request.

I did not found the code though and had to came up with my own but I was able to understand the mistake others were doing as for a normal visitor ?r=1 ?random=1  may sound like a something weird, but www.site.com/random-post/  was a perfect URL with greater user understanding and friendliness. Here is the code:

 

To use this function you need to create an anchor link to:  www.your-site.com/random-post

If it works make sure you leave a comment and give us a bump either by sharing us or give us a +1 on G.