I want to create a dozen or so little (30×30) icons and have one displayed at random in front of each post title. I found several randomizing PHP scripts that’ll do it, and I put the code in post.php where the title is displayed:
<h2 id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent link to <?ph
p the_title();?>"><?php the_title(); ?></a></h2>
This works, kinda. It displays the icon next to the title, so that’s good (example).
But, I have the latest four posts on my index page. They each get the same icon! I want to have a different icon for each post. I suspect this is some arcane use of The Loop, but I’m not sure how to implement this. Any ideas?
I think you might be right, but if the code is called more than once, a different number should be generated (I called the routine several times on its own, and got a different image every time). That’s why I suspect the problem is the way the post.php file is called by the loop.