1 daniel Mar 23, 2007 23:06
3 daniel Mar 24, 2007 17:13
Ah... hours after hours spending on trying to understand your random-image-in-sidebar trick and working out the code one line after the other using several sources explaining stuff (via google) I finally understand how this all works, have revised the script so that it is now working as I wanted to.
I think with this I´m now satisfied!
4 stk Mar 24, 2007 17:51
Yay! Good for you. I bet you learned some stuff! ;)
I'm glad that you were able to modify the code to get what you wanted. :D
5 daniel Mar 24, 2007 21:41
Yeah... thanks very much for the whole idea and work; I only modified it for 2 reasons, first I coudln´t get your script working and second I nedded some litte changes, like the post title should be included etc..
AFAIK, there's no "already-done" method of pulling up a random post.
One would THINK that it'd be as easy as finding the number of posts you've made and picking a random number between ONE and THAT NUMBER, but it's not. Reason: lots of posts end up in the dirt (unpublished, deleted, private, etc.) Can't pick those numbers.
Off the top of my head, it seems that the easiest way (conceptually), would be to query the database for all "published", "public" posts and put their post numbers into an array. Then find out how big that array is (+ indexing), then randomly pick a number from 1 to THAT NUMBER and make a link with http://yoursite.com/index.php?p=$RANDOM_NUMBER .
Should be loads easier than a random image linked to it's respective post. :D
Hope this helps.